Count days between two date - J2ME

我与影子孤独终老i 提交于 2020-01-03 19:30:51

问题


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 the days. Can anyone help ?


回答1:


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



来源:https://stackoverflow.com/questions/7701397/count-days-between-two-date-j2me

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!