@Test
public void toHours() throws Exception {

    // 1 hour
    DateTimePeriod period0 = DateTimePeriod.createHour(2009, 1, 1, 0, DateTimeZone.UTC);
    List<DateTimePeriod> periods = period0.toHours();
    Assert.assertArrayEquals(new DateTimePeriod[] {
            DateTimePeriod.createHour(2009, 1, 1, 0, DateTimeZone.UTC)
        }, periods.toArray(new DateTimePeriod[0]));
    // multiple hours (a little more than an hour)
    period0 = new DateTimeHour(new DateTime(2009,1,1,0,0,0,0,DateTimeZone.UTC), new DateTime(2009,1,1,2,0,0,0,DateTimeZone.UTC));
    periods = period0.toPeriods(DateTimeDuration.HOUR);
    Assert.assertArrayEquals(new DateTimePeriod[] {
            DateTimePeriod.createHour(2009, 1, 1, 0, DateTimeZone.UTC),
            DateTimePeriod.createHour(2009, 1, 1, 1, DateTimeZone.UTC)
        }, periods.toArray(new DateTimePeriod[0]));
    // no hours (partial hour such as 5 minutes)
    period0 = DateTimePeriod.createFiveMinutes(2009, 1, 1, 0, 0, DateTimeZone.UTC);
    periods = period0.toHours();
    Assert.assertArrayEquals(new DateTimePeriod[] {}, periods.toArray(new DateTimePeriod[0]));
}