How can I get the difference in days between a java.util.Date and a Joda-Time DateTime?
Translations
Englishالعربية
български
català
中文
čeština
dansk
Nederlands
eesti
suomi
français
Deutsch
Ελληνικά
עברית
हिंदी
magyar
Bahasa Indonesia
italiano
日本語
한국어
latviešu
lietuvių
norsk
polski
Português
română
русский
slovenčina
slovenski
español
svenska
ไทย
Türkçe
українська
Tiếng Việt
class ReminderInterval{
Date lastDate=Obj.getAccepted(); //it will return a last login date(java.util.Date).
DateTime currentDate=new DateTime(); //it is Joda-Time type
}
Is it possible to find the difference (preferably expressed in terms of the number of days) between a java.util.Date and a Joda-Time DateTime?
This question and answers originated from www.stackoverflow.com
Question by dhn83 (8/4/2011 6:16:55 PM)
Answer |
Just convert Date to DateTime and then use Days#daysBetween(). The DateTime has a constructor taking the time in millis and the Date has a getter returning exaclty that.
DateTime lastDate = new DateTime(Obj.getAccepted().getTime());
DateTime currentDate = new DateTime();
int days = Days.daysBetween(lastDate, currentDate).getDays();
Answer by BalusC
Find More Answers