DateTimePeriod { static public DateTimePeriod createMonth(int year, int month, DateTimeZone zone) { DateTime start = new DateTime(year, month, 1, 0, 0, 0, 0, zone); return createMonth(start); } protected  DateTimePeriod(DateTime start, DateTime end, DateTimeDuration duration, String keyPattern,
            String longNamePattern, String shortNamePattern, String indexNamePattern); DateTime getStart(); DateTime getEnd(); DateTimeDuration getDuration(); String getKey(); String getLongName(); String getShortName(); String getIndexName(); abstract DateTimePeriod getNext(); abstract DateTimePeriod getPrevious(); abstract DateTimeDuration getDefaultSubDuration(); List<DateTimePeriod> toPeriods(DateTimeDuration duration); List<DateTimePeriod> toFiveMinutes(); List<DateTimePeriod> toHours(); List<DateTimePeriod> toDays(); List<DateTimePeriod> toMonths(); List<DateTimePeriod> toYears(); @Override boolean equals(Object object); @Override int hashCode(); static DateTimePeriod create(DateTimeDuration duration, DateTime start); static DateTimePeriod createYear(int year, DateTimeZone zone); static DateTimePeriod createYear(DateTime start); static DateTimePeriod createMonth(int year, int month, DateTimeZone zone); static DateTimePeriod createMonth(DateTime start); static DateTimePeriod createDay(int year, int month, int day, DateTimeZone zone); static DateTimePeriod createDay(DateTime start); static DateTimePeriod createHour(int year, int month, int day, int hour, DateTimeZone zone); static DateTimePeriod createHour(DateTime start); static DateTimePeriod createFiveMinutes(int year, int month, int day, int hour, int minute, DateTimeZone zone); static DateTimePeriod createFiveMinutes(DateTime start); static List<DateTimePeriod> createLastYearMonths(DateTimeZone zone);  }
@Test public void createMonth() throws Exception { DateTimePeriod period0 = DateTimePeriod.createMonth(2009, 2, DateTimeZone.UTC); DateTimePeriod period1 = DateTimePeriod.createMonth(new DateTime(2009,2,1,0,0,0,0,DateTimeZone.UTC)); DateTimePeriod period2 = DateTimePeriod.create(DateTimeDuration.MONTH, new DateTime(2009,2,1,0,0,0,0,DateTimeZone.UTC)); DateTime correctStart = new DateTime(2009,2,1,0,0,0,0,DateTimeZone.UTC); DateTime correctEnd = new DateTime(2009,3,1,0,0,0,0,DateTimeZone.UTC); Assert.assertEquals(correctStart, period0.getStart()); Assert.assertEquals(correctEnd, period0.getEnd()); Assert.assertEquals(DateTimeDuration.MONTH, period0.getDuration()); Assert.assertEquals("2009-02", period0.getKey()); Assert.assertEquals("February 2009", period0.getLongName()); Assert.assertEquals("2009-02", period0.getShortName()); Assert.assertEquals("02", period0.getIndexName()); Assert.assertEquals(correctStart, period1.getStart()); Assert.assertEquals(correctEnd, period1.getEnd()); Assert.assertEquals(DateTimeDuration.MONTH, period1.getDuration()); Assert.assertEquals("2009-02", period1.getKey()); Assert.assertEquals("February 2009", period0.getLongName()); Assert.assertEquals("2009-02", period0.getShortName()); Assert.assertEquals("02", period0.getIndexName()); Assert.assertEquals(correctStart, period2.getStart()); Assert.assertEquals(correctEnd, period2.getEnd()); Assert.assertEquals(DateTimeDuration.MONTH, period2.getDuration()); Assert.assertEquals("2009-02", period2.getKey()); Assert.assertEquals("February 2009", period0.getLongName()); Assert.assertEquals("2009-02", period0.getShortName()); Assert.assertEquals("02", period0.getIndexName()); }