You must use Period to determine the number of months / days / etc .:
Period period = new Period(start, end);
Converting Interval to a period would also be nice, but inconspicuous overloading includes all units of the period - and you did not print the months.
Now, if you only need days, hours, minutes, seconds, you need to create the corresponding PeriodType , for example
PeriodType periodType = PeriodType.dayTime().withMillisRemoved(); Period period = new Period(start, end, periodType);
Then you can request these individual fields, and everything should be fine.
(In fact, you can only use dayTime() , given that millis will not interfere with anything else.)
So, you can either build your period directly from start , and end , as described above, or if you want to keep Interval , you can use:
Period period = interval.toPeriod(periodType);
Jon skeet
source share