【发布时间】:2015-12-19 04:37:36
【问题描述】:
谁能帮我以有效的方式计算Date的天数差异?
Date nextCollectionDate = dispenseNormal.getDispensing().getNextCollectionDate();
Date currentDate = new Date();
int daysDiff = currentDate - nextCollectionDate;
【问题讨论】:
-
您到底期待什么?你得到什么?有什么问题?
-
我想以天为单位计算两个日期之间的差异。
-
使用 Java 8 的 Time API、JodaTime 甚至 Calendar
-
另一个选项是使用
GregorianCalendar