开发者

Count days between two date - J2ME

开发者 https://www.devze.com 2023-04-11 13:13 出处:网络
I want to count days between two date, I found some solutions on the net but the problem is in my NetBeans the GregorianCalendar is not available. So cant calculate 开发者_StackOverflow社区the days. C

I want to count days between two date, I found some solutions on the net but the problem is in my NetBeans the GregorianCalendar is not available. So cant calculate 开发者_StackOverflow社区the days. Can anyone help ?


In Java Micro Edition you don't have GregorianCalendar, so you have to use:

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

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

0

精彩评论

暂无评论...
验证码 换一张
取 消