calculating number of days between 2 dates chosen in jdateChooser

I have this problem where i cannot figure out a way to calculate the number of days between 2 dates that the user chooses using a jDateChooser ( in netbeans)... so i need help please ... what is the function or stack of commands to realise that ?

Re: calculating number of days between 2 dates chosen in jdateChooser

You can extract the long values that represent the values of those dates. This give you date information in milliseconds. Subtract the first date with the second will give you the different in milliseconds. To get the values in days you need to divide the milliseconds value with (24 * 60 * 60 * 1000).

Another way is to use the Joda Time, and it will be much simpler, the snippet look like this.

Code:

`import org.joda.time.DateMidnight;`

import org.joda.time.Days;

...

DateMidnight start = new DateMidnight("2010-02-01");

DateMidnight end = new DateMidnight("2012-02-07");

int days = Days.daysBetween(start, end).getDays();

...