}
@Override
public Calendar getCalendar(Integer year, Integer month) {
Calendar calendar = new Calendar();
// build months
List<DateTime> months = calendar.getMonths();
DateMidnight thisMonth = getDefaultDateTime().toDateMidnight().withDayOfMonth(1);
months.add(thisMonth.toDateTime());
// display last 6 months
while (months.size() < 6) {
thisMonth = thisMonth.minusMonths(1);
months.add(thisMonth.toDateTime());
}
reverse(months);
// build selectedMonth
if (year != null) {
notNull(month, "month is required if year is specified");
DateTime selectedMonth = new DateMidnight().withDayOfMonth(1).withYear(year).withMonthOfYear(month).toDateTime();
calendar.setSelectedMonth(selectedMonth);
}
return calendar;
}