I started playing with JodaTime and I failed to find a handy way to calculate the difference in days between 2 DateTime objects. The best I came up with is below:
//given DateTime dt1 and dt2
long distanceInMillis = dt2.getMillis()-dt1.getMillis();
int distanceInDays = (int)(distanceInMillis / 24*60*60*1000L);
I would appreciate your suggestion of how this can be done better.
Nooooooo! So many Daylight Savings bugs from counting days using milliseconds 🙂
Joda provides