DateTimeHour extends DateTimePeriod { @Override public DateTimePeriod getPrevious() { DateTime previous = getStart().minusHours(1); return DateTimePeriod.createHour(previous); } protected  DateTimeHour(DateTime start, DateTime end); @Override DateTimePeriod getNext(); @Override DateTimePeriod getPrevious(); @Override DateTimeDuration getDefaultSubDuration();  }
@Test public void getPrevious() throws Exception { DateTimePeriod period0 = DateTimePeriod.createHour(2009, 1, 1, 0, DateTimeZone.UTC); DateTimePeriod period1 = period0.getPrevious(); DateTime correctStart = new DateTime(2008,12,31,23,0,0,0,DateTimeZone.UTC); DateTime correctEnd = new DateTime(2009,1,1,0,0,0,0,DateTimeZone.UTC); Assert.assertEquals(correctStart, period1.getStart()); Assert.assertEquals(correctEnd, period1.getEnd()); }