计算两个日期之间的天数-J2ME [英] Count days between two date - J2ME
本文介绍了计算两个日期之间的天数-J2ME的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想计算两个日期之间的天数,我在网上找到了一些解决方案,但是问题出在我的NetBeans中, GregorianCalendar 不可用.因此无法计算天数.有人可以帮忙吗?
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 ?
推荐答案
在Java Micro Edition中,您没有GregorianCalendar,因此必须使用:
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));
日期returns the number of milliseconds since January 1, 1970, 00:00:00 GMT
这篇关于计算两个日期之间的天数-J2ME的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文