I need help to get the Period between two Java Dates. I use JodaTime for the calculation but the result isn't correct.
Start: 11.11.2012 12:00
End: 16.12.2012 20:15
(German time standard)
Result musst be 5 weeks, 0 days, 8 hours and 15 minutes.
I try it with
Period period = new Period( start.getTime(), end.getTime() );
weeks = Weeks.weeksBetween( new DateTime( start ), new DateTime( end ) ).getWeeks();
days = period.getDays();
hours = period.getHours();
minutes = period.getMinutes();
and got 5w 5d 8h 15m.
EDIT:
Thanks for the help but i think i use the JodaTime Period wrong. Off course is the output of 5w 5d 8h 15m right but what i want is more like this.
int days = Days.daysBetween( start, end ); // musst be 35 days
int weeks = ( days - ( days % 7 ) ) / 7;
days = days % 7;
Now is my result 5 weeks and 0 days. Sorry for the confusion and thanks for the help.