if(recurDates == null) return lstDates;
for( Object obj : recurDates ) {
net.fortuna.ical4j.model.Date date = (net.fortuna.ical4j.model.Date)obj;
KalendarRecurEvent recurEvent;
java.util.Calendar eventStartCal = java.util.Calendar.getInstance();
eventStartCal.clear();
eventStartCal.setTime(kEvent.getBegin());
java.util.Calendar eventEndCal = java.util.Calendar.getInstance();
eventEndCal.clear();
eventEndCal.setTime(kEvent.getEnd());
java.util.Calendar recurStartCal = java.util.Calendar.getInstance();
recurStartCal.clear();
recurStartCal.setTimeInMillis(date.getTime());
long duration = kEvent.getEnd().getTime() - kEvent.getBegin().getTime();
java.util.Calendar beginCal = java.util.Calendar.getInstance();
beginCal.clear();
beginCal.set(
recurStartCal.get(java.util.Calendar.YEAR),
recurStartCal.get(java.util.Calendar.MONTH),
recurStartCal.get(java.util.Calendar.DATE),
eventStartCal.get(java.util.Calendar.HOUR_OF_DAY),
eventStartCal.get(java.util.Calendar.MINUTE),
eventStartCal.get(java.util.Calendar.SECOND)
);
java.util.Calendar endCal = java.util.Calendar.getInstance();
endCal.clear();
endCal.setTimeInMillis(beginCal.getTimeInMillis() + duration);
if(kEvent.getBegin().compareTo(beginCal.getTime()) == 0) continue; //prevent doubled events
Date recurrenceEnd = CalendarUtils.getRecurrenceEndDate(kEvent.getRecurrenceRule());
if(kEvent.isAllDayEvent() && recurrenceEnd != null && recurStartCal.getTime().after(recurrenceEnd)) continue; //workaround for ical4j-bug in all day events
recurEvent = new KalendarRecurEvent(kEvent.getID(), kEvent.getSubject(), new Date(beginCal.getTimeInMillis()), new Date(endCal.getTimeInMillis()));
recurEvent.setSourceEvent(kEvent);
lstDates.add(recurEvent);
}
return lstDates;
}