@Test
public void toMonths() throws Exception {

    // 1 month
    DateTimePeriod period0 = DateTimePeriod.createMonth(2009, 1, DateTimeZone.UTC);
    List<DateTimePeriod> periods = period0.toMonths();
    Assert.assertArrayEquals(new DateTimePeriod[] {
            DateTimePeriod.createMonth(2009, 1, DateTimeZone.UTC)
        }, periods.toArray(new DateTimePeriod[0]));
    // multiple months (a little more than 1 more month)
    period0 = new DateTimeMonth(new DateTime(2009,1,1,0,0,0,0,DateTimeZone.UTC), new DateTime(2009,3,1,1,0,0,0,DateTimeZone.UTC));
    periods = period0.toPeriods(DateTimeDuration.MONTH);
    Assert.assertArrayEquals(new DateTimePeriod[] {
            DateTimePeriod.createMonth(2009, 1, DateTimeZone.UTC),
            DateTimePeriod.createMonth(2009, 2, DateTimeZone.UTC)
        }, periods.toArray(new DateTimePeriod[0]));
    // no months (partial month such as a day)
    period0 = DateTimePeriod.createDay(2009, 1, 1, DateTimeZone.UTC);
    periods = period0.toMonths();
    Assert.assertArrayEquals(new DateTimePeriod[] {}, periods.toArray(new DateTimePeriod[0]));
}