开发者

How do I calculate the date difference?

How to calculate the date difference in A开发者_如何学编程ndroid?


If you can't afford 3rd party libraries like JodaTime, then your best bet is really java.util.Calendar. You can use the Calendar#add() method in a loop to calculate the difference in years, months and days between two instances. Then to calculate the difference in hours, minutes and seconds, just do the usual math on Calendar#getTimeInMillis().

Long story short, I've posted a basic example before here. You may find it useful.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜