Is there a better way of doing this?
boolean oneCalendarWeek = interval.getStart().plusWeeks(1).equals( interval.getEnd() );
I guess the following won’t work because of the way equals is implemented…
boolean oneCalendarWeek = interval.toPeriod().equals( Weeks.ONE );
From the comments:
While the example using
Weeks.ONEdoes not work (sincePeriod.equals()first checks if the twoPeriodinstances support the same number of fields, andWeeks.ONEonly supports one field), this should work instead:Here is a code sample that tests this for an interval that starts before the start of DST and ends while in DST. However, I’m not 100% sure how this would behave if the start or end time of the Interval fell exactly on the DST boundary.