java - Number of days between two dates in Joda-Time -


How can I find the difference between the two examples? With 'difference in days', I mean that the beginning is on Monday and the end is on Tuesday, I expect the return value of 1 regardless of the hours / minutes / second of the start and end dates.

starts days (start, end) .getDays () gives me 0 if the evening starts and ends in the morning.

I have the same problem with other date fields, so I was hoping that there would be a common way of 'ignoring' areas of low importance

In other words, February And between the months of March 4 will also be 1, as are the hours between 14:45 and 15:12. However, the difference difference between 14:01 and 14:55 is 0.

Anger, withTimeAtStartOfDay answer is incorrect, but only occasionally you want:

< Between pre-> days (start.TolocationDate), end. Toolkoltet ()). GetDays ()

It has been discovered that "midnight / day start" sometimes means 1:00 (daylight savings in some places this way), the day Does not handle properly in days.

  // 21 to 21 a.m. to 20 o'clock, October 2013, Brazilian datetimeJohn Brazil = datetimejone Ford ("America / Sao Polo"); Date Time Start = New Date Time (2013, 10, 20, 5, 0, 0, Brazil); Date Time End = New Date Time (2013, 10, 21, 13, 0, 0, Brazil); System.out.println (between days (start.withTimeAtStartOfDay (), end withTime startup (). GetDays ()); // print 0 system.out.println (between days (start.toLocalDate), end.toLocalDate ()). GetDays ()); // print 1  

going through a local code sidesteps to the whole issue


Comments