繁体   English   中英

找出java.util.Date和Joda-Time DateTime之间的天数差异?

[英]Find the difference in days between a java.util.Date and a Joda-Time DateTime?

是否有可能找到java.util.Date和Joda-Time DateTime之间的差异(最好以天数表示)?

class ReminderInterval{
    //it will return a last login date(java.util.Date)
    Date lastDate=Obj.getAccepted();

    //it is Joda-Time type
    DateTime currentDate=new DateTime();
}

只需将Date转换为DateTime ,然后使用Days#daysBetween() DateTime有一个构造函数,以毫秒为单位, Date有一个getter返回exaclty。

DateTime lastDate = new DateTime(Obj.getAccepted().getTime());
DateTime currentDate = new DateTime();
int days = Days.daysBetween(lastDate, currentDate).getDays();

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM