Java date difference days

See English answers > Android / Java – date difference in days 18

Date nextCollectionDate = dispenseNormal.getDispensing().getNextCollectionDate();
Date currentDate = new Date();
int daysDiff = currentDate - nextCollectionDate;

Solution

//diff in msec
//diff in msec
long diff = currentDate.getTime() - nextCollectionDate.getTime();

//diff in days
long days = diff / (24 * 60 * 60 * 1000);
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>