recur.setCount(event.getRecurrenceNumberOfTimes());
for(RecurrenceInWeek day : event.getRecurrenceInWeek())
{
if (day.getCalendarValue() == java.util.Calendar.MONDAY)
recur.getDayList().add(new WeekDay("MO"));
if (day.getCalendarValue() == java.util.Calendar.TUESDAY)
recur.getDayList().add(new WeekDay("TU"));
if (day.getCalendarValue() == java.util.Calendar.WEDNESDAY)
recur.getDayList().add(new WeekDay("WE"));
if (day.getCalendarValue() == java.util.Calendar.THURSDAY)
recur.getDayList().add(new WeekDay("TH"));
if (day.getCalendarValue() == java.util.Calendar.FRIDAY)
recur.getDayList().add(new WeekDay("FR"));
if (day.getCalendarValue() == java.util.Calendar.SATURDAY)
recur.getDayList().add(new WeekDay("SA"));
if (day.getCalendarValue() == java.util.Calendar.SUNDAY)
recur.getDayList().add(new WeekDay("SU"));
}
if(event.getRecurrenceInMonth() == EventVO.RecurrenceInMonth.DAY_OF_MONTH)
{
java.util.Calendar cal = GregorianCalendar.getInstance();
cal.setFirstDayOfWeek(mainCalendar.getFirstDayOfWeek().getDay());
cal.setTime(event.getStartDate());
recur.getMonthDayList().add(cal.get(java.util.Calendar.DAY_OF_MONTH));
}
else if(event.getRecurrenceInMonth() == EventVO.RecurrenceInMonth.DAY_OF_WEEK)
{
java.util.Calendar cal = GregorianCalendar.getInstance();
cal.setFirstDayOfWeek(mainCalendar.getFirstDayOfWeek().getDay());
cal.setTime(event.getStartDate());
int week = cal.get(java.util.Calendar.WEEK_OF_MONTH);
int day = cal.get(java.util.Calendar.DAY_OF_WEEK);
if (day== java.util.Calendar.MONDAY)
recur.getDayList().add(new WeekDay(week + "MO"));
if (day == java.util.Calendar.TUESDAY)
recur.getDayList().add(new WeekDay(week + "TU"));
if (day == java.util.Calendar.WEDNESDAY)
recur.getDayList().add(new WeekDay(week + "WE"));
if (day == java.util.Calendar.THURSDAY)
recur.getDayList().add(new WeekDay(week + "TH"));
if (day == java.util.Calendar.FRIDAY)
recur.getDayList().add(new WeekDay(week + "FR"));
if (day == java.util.Calendar.SATURDAY)
recur.getDayList().add(new WeekDay(week + "SA"));
if (day == java.util.Calendar.SUNDAY)
recur.getDayList().add(new WeekDay(week + "SU"));
}
recur.setWeekStartDay("MO");
return new RRule(recur);
}