/** * Applies BYMONTH rules specified in this Recur instance to the specified date list. If no BYMONTH rules are * specified the date list is returned unmodified. * * @param dates * @return */ private DateList getMonthVariants(final DateList dates) { if (getMonthList().isEmpty()) { return dates; } final DateList monthlyDates = getDateListInstance(dates); for (final Date date : dates) { final Calendar cal = getCalendarInstance(date, true); final Calendar freqEnd = getCalendarInstance(date, true); increment(freqEnd); for (final Integer month : getMonthList()) { // Java months are zero-based.. // cal.set(Calendar.MONTH, month.intValue() - 1); cal.roll(Calendar.MONTH, (month - 1) - cal.get(Calendar.MONTH)); if (cal.after(freqEnd)) { break; // Do not break out of the FREQ-defined boundary } monthlyDates.add(Dates.getInstance(cal.getTime(), monthlyDates.getType())); } } return monthlyDates; }
/** * Applies BYMONTH rules specified in this Recur instance to the specified date list. If no BYMONTH rules are * specified the date list is returned unmodified. * * @param dates * @return */ private DateList getMonthVariants(final DateList dates) { if (getMonthList().isEmpty()) { return dates; } final DateList monthlyDates = getDateListInstance(dates); for (final Date date : dates) { final Calendar cal = getCalendarInstance(date, true); final Calendar freqEnd = getCalendarInstance(date, true); increment(freqEnd); for (final Integer month : getMonthList()) { // Java months are zero-based.. // cal.set(Calendar.MONTH, month.intValue() - 1); cal.roll(Calendar.MONTH, (month - 1) - cal.get(Calendar.MONTH)); if (cal.after(freqEnd)) { break; // Do not break out of the FREQ-defined boundary } monthlyDates.add(Dates.getInstance(cal.getTime(), monthlyDates.getType())); } } return monthlyDates; }