Java Code Examples for net.fortuna.ical4j.model.Recur#setUntil()
The following examples show how to use
net.fortuna.ical4j.model.Recur#setUntil() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ThisAndFutureHelper.java From cosmo with Apache License 2.0 | 6 votes |
private void modifyOldSeries(NoteItem oldSeries, Date lastRecurrenceId) { EventStamp event = StampUtils.getEventStamp(oldSeries); // We set the end date to 1 second before the begining of the next day java.util.Calendar untilDateCalendar = java.util.Calendar.getInstance(TimeZone.getTimeZone("GMT")); untilDateCalendar.setTime(lastRecurrenceId); untilDateCalendar.add(java.util.Calendar.DAY_OF_MONTH, -1); untilDateCalendar.set(java.util.Calendar.HOUR_OF_DAY, 23); untilDateCalendar.set(java.util.Calendar.MINUTE, 59); untilDateCalendar.set(java.util.Calendar.SECOND, 59); Date untilDate = Dates.getInstance(untilDateCalendar.getTime(), lastRecurrenceId); // UNTIL must be UTC according to spec if(untilDate instanceof DateTime) { ((DateTime) untilDate).setUtc(true); } List<Recur> recurs = event.getRecurrenceRules(); for (Recur recur : recurs) { recur.setUntil(untilDate); } // TODO: Figure out what to do with RDATEs }
Example 2
Source File: ICal4JUtils.java From projectforge-webapp with GNU General Public License v3.0 | 6 votes |
/** * * @param rruleString * @return null if rruleString is empty, otherwise new RRule object. */ public static RRule calculateRecurrenceRule(final String rruleString) { if (StringUtils.isBlank(rruleString) == true) { return null; } try { final RRule rule = new RRule(rruleString); // set the recurrence end date to the last minute of the day final Recur recur = rule.getRecur(); final net.fortuna.ical4j.model.Date until = recur != null ? recur.getUntil() : null; if (until != null) { final Date untilEndOfDay = CalendarUtils.getEndOfDay(until, PFUserContext.getTimeZone()); recur.setUntil(new net.fortuna.ical4j.model.Date(untilEndOfDay)); } return rule; } catch (final ParseException ex) { log.error("Exception encountered while parsing rrule '" + rruleString + "': " + ex.getMessage(), ex); return null; } }
Example 3
Source File: TeamEventUtils.java From projectforge-webapp with GNU General Public License v3.0 | 6 votes |
public static String calculateRRule(final TeamEventRecurrenceData recurData) { if (recurData == null || recurData.getFrequency() == null || recurData.getFrequency() == RecurrenceFrequency.NONE) { return null; } if (recurData.isCustomized() == false) { recurData.setInterval(1); } final Recur recur = new Recur(); final net.fortuna.ical4j.model.Date untilDate = ICal4JUtils.getICal4jDate(recurData.getUntil(), recurData.getTimeZone()); if (untilDate != null) { recur.setUntil(untilDate); } recur.setInterval(recurData.getInterval()); recur.setFrequency(ICal4JUtils.getCal4JFrequencyString(recurData.getFrequency())); final RRule rrule = new RRule(recur); return rrule.getValue(); }
Example 4
Source File: ICal4JUtilsTest.java From projectforge-webapp with GNU General Public License v3.0 | 6 votes |
@Test public void recurTests() { final TimeZone timeZone = DateHelper.EUROPE_BERLIN; final Recur recur = new Recur(); recur.setFrequency(ICal4JUtils.getCal4JFrequencyString(RecurrenceFrequency.WEEKLY)); recur.setUntil(getDate("2013-01-31", timeZone)); recur.setInterval(2); final DateList dateList = recur.getDates(getDate("2013-01-01", timeZone), getDate("2012-01-02", timeZone), getDate("2013-03-31", timeZone), Value.TIME); Assert.assertEquals(3, dateList.size()); final DateFormat df = new SimpleDateFormat(DateFormats.ISO_TIMESTAMP_MINUTES); df.setTimeZone(timeZone); Assert.assertEquals("2013-01-01 00:00", df.format(dateList.get(0))); Assert.assertEquals("2013-01-15 00:00", df.format(dateList.get(1))); Assert.assertEquals("2013-01-29 00:00", df.format(dateList.get(2))); }
Example 5
Source File: Calendar_EventServiceAdv.java From o2oa with GNU Affero General Public License v3.0 | 4 votes |
/** * 删除重复日程事件中某一事件开始后续所有的日程事件信息(一定是重复日程) * * 1、删除当前事件以及该重复事件主体信息已经生成的该ID事件后续时间内所有已经生成的日程事件信息 * 2、更新日程事件重复信息主体,将截止日期改为指定ID所在的日期的前一天的23:59:59 * * @param repeatMasterId * @param calendar_event * @return * @throws Exception */ public Integer destoryAfterEventId( String repeatMasterId, Calendar_Event calendar_event ) throws Exception { if( StringUtils.isEmpty( repeatMasterId )) { throw new Exception("calendar repeat master id is empty, calendar can not delete!" ); } if( calendar_event == null ) { throw new Exception("calendar event is null, calendar can not delete!" ); } Integer count = 0; Business business = null; List<String> eventIds = null; List<Calendar_Event> calendarEvents = null; Calendar_EventRepeatMaster calendar_EventRepeatMaster = null; try ( EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) { business = new Business(emc); calendar_EventRepeatMaster = emc.find( calendar_event.getRepeatMasterId(), Calendar_EventRepeatMaster.class ); //----------------------------------------------------------------------------------------------------------------- //1、删除当前事件以及该重复事件主体信息已经生成的该ID事件后续时间内所有已经生成的日程事件信息 eventIds = business.calendar_EventFactory().listWithRepeatMaster(repeatMasterId, calendar_event.getStartTime(), null ); if( ListTools.isNotEmpty( eventIds )) { count = eventIds.size(); calendarEvents = business.calendar_EventFactory().list( eventIds ); } if( ListTools.isNotEmpty( calendarEvents )) { emc.beginTransaction( Calendar_Event.class ); for( Calendar_Event calendar_Event : calendarEvents ) { emc.remove( calendar_Event, CheckRemoveType.all ); } } //将截止日期改为指定ID所在的日期的前一天的23:59:59 Date repeatEndTime = dateOperation.getEndTimeInDay( dateOperation.getDayAddDate( calendar_event.getStartTime(), -1 ) ); RRule rule = new RRule( calendar_EventRepeatMaster.getRecurrenceRule() ); Recur recur = rule.getRecur(); recur.setUntil( new net.fortuna.ical4j.model.Date(repeatEndTime) ); calendar_EventRepeatMaster.setRecurrenceRule( new RRule(recur).getValue()); emc.beginTransaction( Calendar_EventRepeatMaster.class ); emc.check( calendar_EventRepeatMaster, CheckPersistType.all ); emc.commit(); } catch ( Exception e ) { throw e; } return count; }
Example 6
Source File: Calendar_EventServiceAdv.java From o2oa with GNU Affero General Public License v3.0 | 4 votes |
/** * 删除重复日程事件中某一事件开始后续所有的日程事件信息(一定是重复日程) * * 1、删除当前事件以及该重复事件主体信息已经生成的该ID事件后续时间内所有已经生成的日程事件信息 * 2、更新日程事件重复信息主体,将截止日期改为指定ID所在的日期的前一天的23:59:59 * * @param repeatMasterId * @param calendar_event * @return * @throws Exception */ public Integer destoryAfterEventId( String repeatMasterId, Calendar_Event calendar_event ) throws Exception { if( StringUtils.isEmpty( repeatMasterId )) { throw new Exception("calendar repeat master id is empty, calendar can not delete!" ); } if( calendar_event == null ) { throw new Exception("calendar event is null, calendar can not delete!" ); } Integer count = 0; Business business = null; List<String> eventIds = null; List<Calendar_Event> calendarEvents = null; Calendar_EventRepeatMaster calendar_EventRepeatMaster = null; try ( EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) { business = new Business(emc); calendar_EventRepeatMaster = emc.find( calendar_event.getRepeatMasterId(), Calendar_EventRepeatMaster.class ); //----------------------------------------------------------------------------------------------------------------- //1、删除当前事件以及该重复事件主体信息已经生成的该ID事件后续时间内所有已经生成的日程事件信息 eventIds = business.calendar_EventFactory().listWithRepeatMaster(repeatMasterId, calendar_event.getStartTime(), null ); if( ListTools.isNotEmpty( eventIds )) { count = eventIds.size(); calendarEvents = business.calendar_EventFactory().list( eventIds ); } if( ListTools.isNotEmpty( calendarEvents )) { emc.beginTransaction( Calendar_Event.class ); for( Calendar_Event calendar_Event : calendarEvents ) { emc.remove( calendar_Event, CheckRemoveType.all ); } } //将截止日期改为指定ID所在的日期的前一天的23:59:59 Date repeatEndTime = dateOperation.getEndTimeInDay( dateOperation.getDayAddDate( calendar_event.getStartTime(), -1 ) ); RRule rule = new RRule( calendar_EventRepeatMaster.getRecurrenceRule() ); Recur recur = rule.getRecur(); recur.setUntil( new net.fortuna.ical4j.model.Date(repeatEndTime) ); calendar_EventRepeatMaster.setRecurrenceRule( new RRule(recur).getValue()); emc.beginTransaction( Calendar_EventRepeatMaster.class ); emc.check( calendar_EventRepeatMaster, CheckPersistType.all ); emc.commit(); } catch ( Exception e ) { throw e; } return count; }