Days Between Two Dates - J2ME

I want to count the days between two dates, I found some solutions on the net, but the problem in my NetBeans GregorianCalendar is not available. So I can’t calculate the days. Can anyone help?

+4
source share
1 answer

In Java Micro Edition you do not have GregorianCalendar, so you need to use:

Date startDate, endDate;
...
int days = (int) ((endDate.getTime() - startDate.getTime())  
    / (1000 * 60 * 60 * 24)); 

Where is the getTime () Date method returns the number of milliseconds since January 1, 1970, 00:00:00 GMT

+5
source

All Articles