DateTimePeriodSelector { static public DateTimePeriod lastMonth(DateTimeZone zone) { return thisMonth(zone).getPrevious(); } private  DateTimePeriodSelector(); static DateTimePeriod thisMonth(DateTimeZone zone); static DateTimePeriod lastMonth(DateTimeZone zone); static List<DateTimePeriod> last12Months(DateTimeZone zone);  }
@Test public void lastMonth() throws Exception { DateTimePeriod period = DateTimePeriodSelector.lastMonth(DateTimeZone.UTC); DateTime now = new DateTime(DateTimeZone.UTC); now = now.minusMonths(1); DateTimePeriod expectedPeriod = DateTimePeriod.createMonth(now.getYear(), now.getMonthOfYear(), DateTimeZone.UTC); Assert.assertEquals(expectedPeriod, period); }