Вот пример для моего правила повторения для того же самого Еженедельное правило повторения равно
RRULE:FREQ=MONTHLY;INTERVAL=1;BYDAY=MO;UNTIL=20161222T000000Z
RRULE:FREQ=MONTHLY;INTERVAL=<Every month/with some interval>;BYDAY=<Day of week>;UNTIL=<Until Date>
Так что согласно этому ваше правило будет выглядеть так: "RRULE:FREQ=MONTHLY;INTERVAL=1;BYDAY=MO;UNTIL=20111212T000000Z"
Приведен код для создания правила повторения и дат
class CreateRule{
static {
weekMap.put(Short.valueOf("0"), "SU");
weekMap.put(Short.valueOf("1"), "MO");
weekMap.put(Short.valueOf("2"), "TU");
weekMap.put(Short.valueOf("3"), "WE");
weekMap.put(Short.valueOf("4"), "TH");
weekMap.put(Short.valueOf("5"), "FR");
weekMap.put(Short.valueOf("6"), "SA");
}
Short repeatCountMonthly = repeatCount != null ? repeatCount : 0;
String weekDay = weekMap.get(<repeatMonthWeek>);
//Create recurrence Rule
String monthlyRecurrenceRule = DateUtils.getMonthlyRecurrenceRule(repeatCountMonthly,endsNever, endsAfterOccurrences,endTime,repeatMonthDay,weekDay);
//Create recurrence Dates
Set<LocalDate> monthlyStartDates = CalendarUtils.getRecurrenceDates(monthlyRecurrenceRule,
LocalDate.fromDateFields(startDate));
}
В классе будут методы для создания правила и создания дат:
class DateUtils{
public static String getMonthlyRecurrenceRule(Short interval,boolean endsNever,Integer occurrences, StringBuilder endTime,Short dayOfMonth,String dayOfWeek){
StringBuilder monthlyRecurrenceRule = new StringBuilder("RRULE:FREQ=MONTHLY");
if(interval!=null&&interval.intValue()>0)
monthlyRecurrenceRule.append(";INTERVAL=").append(interval.toString());
if(dayOfMonth!=null && dayOfMonth>0)
monthlyRecurrenceRule.append(";BYMONTHDAY=").append(dayOfMonth.toString());
else
monthlyRecurrenceRule.append(";BYDAY=").append(dayOfWeek);
if(endsNever){
//set endtime as startdate+10 years
monthlyRecurrenceRule.append(";UNTIL=").append("20271231T090000Z");
}
else{
if(occurrences!=null&&occurrences.intValue()>0)
monthlyRecurrenceRule.append(";COUNT=").append(occurrences.toString());
else
monthlyRecurrenceRule.append(";UNTIL=").append(endTime.toString());
}
return monthlyRecurrenceRule.toString();
}
public static Set<LocalDate> getRecurrenceDates(String rRule,LocalDate startDate) throws ParseException{
Set<LocalDate> recurrenceDates = new HashSet<LocalDate>();
for (LocalDate date : LocalDateIteratorFactory.createLocalDateIterable(rRule, startDate, true)) {
recurrenceDates.add(date);
}
return recurrenceDates;
}
}