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

Is it possible to find the difference (preferably expressed in terms of the number of days) between a java.util.Date and 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(); } 
+4
source share
1 answer

Just convert Date to DateTime and then use Days#daysBetween() . DateTime has a getter constructor that returns exaccty, which.

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

All Articles