@Test
public void toYears() throws Exception {

    // 1 year
    DateTimePeriod period0 = DateTimePeriod.createYear(2009, DateTimeZone.UTC);
    List<DateTimePeriod> periods = period0.toYears();
    Assert.assertArrayEquals(new DateTimePeriod[] {
            DateTimePeriod.createYear(2009, DateTimeZone.UTC)
        }, periods.toArray(new DateTimePeriod[0]));
    // multiple years (a little more than 1 more year)
    period0 = new DateTimeYear(new DateTime(2009,1,1,0,0,0,0,DateTimeZone.UTC), new DateTime(2011,2,1,0,0,0,0,DateTimeZone.UTC));
    periods = period0.toPeriods(DateTimeDuration.YEAR);
    Assert.assertArrayEquals(new DateTimePeriod[] {
            DateTimePeriod.createYear(2009, DateTimeZone.UTC),
            DateTimePeriod.createYear(2010, DateTimeZone.UTC)
        }, periods.toArray(new DateTimePeriod[0]));
    // no years (partial year such as a month)
    period0 = DateTimePeriod.createMonth(2009, 1, DateTimeZone.UTC);
    periods = period0.toYears();
    Assert.assertArrayEquals(new DateTimePeriod[] {}, periods.toArray(new DateTimePeriod[0]));
}