PriorityQueue<VEvent> plan = new PriorityQueue<VEvent>(10, new Comparator<VEvent>() { @Override public int compare(VEvent e1, VEvent e2) { Date d1 = e1.getStartDate().getDate(); Date d2 = e2.getStartDate().getDate(); return d1.compareTo(d2); } });
protected boolean isAllDay(final VEvent vEvent) { final DtStart dtStart = vEvent.getStartDate(); return dtStart != null && dtStart.getDate() instanceof net.fortuna.ical4j.model.DateTime == false; }
@Override void mapToBean(net.fortuna.ical4j.model.Calendar cal, Object bean, PropertyDescriptor pd) { VEvent vevent = event(cal); Date dt = null; if( vevent != null ) { dt = getDateValue(vevent.getStartDate()); } else { VFreeBusy fb = freeBusy(cal); if (fb != null) { dt = getDateValue(fb.getStartDate()); } } propertyAccessor.set(bean, pd.getWriteMethod(), dt); }
public Date getStartDate() { VEvent event = getEvent(); if(event==null) { return null; } DtStart dtStart = event.getStartDate(); if (dtStart == null) { return null; } return dtStart.getDate(); }
public Date getStartDate() { VEvent event = getEvent(); if(event==null) { return null; } DtStart dtStart = event.getStartDate(); if (dtStart == null) { return null; } return dtStart.getDate(); }
public int compare(Calendar o1, Calendar o2) { VEvent e1 = ICalendarUtils.getFirstEvent(o1); VEvent e2 = ICalendarUtils.getFirstEvent(o2); return e1.getStartDate().getDate().compareTo(e2.getStartDate().getDate()); }
public Boolean isAnyTime() { DtStart dtStart = getEvent().getStartDate(); if (dtStart == null) { return Boolean.FALSE; } Parameter parameter = dtStart.getParameters() .getParameter(PARAM_X_OSAF_ANYTIME); if (parameter == null) { return Boolean.FALSE; } return Boolean.valueOf(VALUE_TRUE.equals(parameter.getValue())); }
public Boolean isAnyTime() { DtStart dtStart = getEvent().getStartDate(); if (dtStart == null) { return Boolean.FALSE; } Parameter parameter = dtStart.getParameters() .getParameter(PARAM_X_OSAF_ANYTIME); if (parameter == null) { return Boolean.FALSE; } return Boolean.valueOf(VALUE_TRUE.equals(parameter.getValue())); }
@Override public boolean fromVEvent(final TeamEventDO event, final VEvent vEvent) { final DtStart dtStart = vEvent.getStartDate(); if (dtStart == null) { return false; } event.setAllDay(this.isAllDay(vEvent)); event.setStartDate(ICal4JUtils.getSqlTimestamp(dtStart.getDate())); return true; } }
private static boolean isOutOfRange(BaseEventStamp eventStamp, List<StampFilter> stampFilters) throws ParseException { for (StampFilter stampFilter : stampFilters) { if (!(stampFilter instanceof EventStampFilter)) { continue; } VEvent vEvent = null; if (eventStamp instanceof EventStamp) { vEvent = ((EventStamp) eventStamp).getMasterEvent(); } else if (eventStamp instanceof EventExceptionStamp) { vEvent = ((EventExceptionStamp) eventStamp).getExceptionEvent(); } else { throw new ExternalContentRuntimeException("Unknown event stamp class: " + eventStamp.getClass()); } EventStampFilter eventFilter = (EventStampFilter) stampFilter; Date dtStart = vEvent.getStartDate().getDate(); Date dtEnd = vEvent.getEndDate().getDate(); Date filterStartDate = new DateTime(eventFilter.getUTCStart()); Date filterEndDate = new DateTime(eventFilter.getUTCEnd()); if (dtStart.after(filterEndDate) || dtStart.equals(filterEndDate) || dtEnd.before(filterStartDate) || dtEnd.equals(filterStartDate)) { return true; } } return false; }
public void setAnyTime(Boolean isAnyTime) { DtStart dtStart = getEvent().getStartDate(); if (dtStart == null) { throw new IllegalStateException("event has no start date"); } Parameter parameter = dtStart.getParameters().getParameter( PARAM_X_OSAF_ANYTIME); // add X-OSAF-ANYTIME if it doesn't exist if (parameter == null && Boolean.TRUE.equals(isAnyTime)) { dtStart.getParameters().add(getAnyTimeXParam()); return; } // if it exists, update based on isAnyTime if (parameter != null) { dtStart.getParameters().remove(parameter); if (Boolean.TRUE.equals(isAnyTime)) { dtStart.getParameters().add(getAnyTimeXParam()); } } }
public void setAnyTime(Boolean isAnyTime) { DtStart dtStart = getEvent().getStartDate(); if (dtStart == null) { throw new IllegalStateException("event has no start date"); } Parameter parameter = dtStart.getParameters().getParameter( PARAM_X_OSAF_ANYTIME); // add X-OSAF-ANYTIME if it doesn't exist if (parameter == null && Boolean.TRUE.equals(isAnyTime)) { dtStart.getParameters().add(getAnyTimeXParam()); return; } // if it exists, update based on isAnyTime if (parameter != null) { dtStart.getParameters().remove(parameter); if (Boolean.TRUE.equals(isAnyTime)) { dtStart.getParameters().add(getAnyTimeXParam()); } } }
public void setStartDate(Date date) { DtStart dtStart = getEvent().getStartDate(); if (dtStart != null) { dtStart.setDate(date); } else { dtStart = new DtStart(date); getEvent().getProperties().add(dtStart); } setDatePropertyValue(dtStart, date); }
private static boolean isEventValid(VEvent event, ValidationConfig config) { if (config == null) { LOG.error("ValidationConfig cannot be null"); return false; } DtStart startDate = event.getStartDate(); DtEnd endDate = event.getEndDate(true); if (startDate == null || startDate.getDate() == null || endDate != null && startDate.getDate().after(endDate.getDate())) { return false; } for (PropertyValidator validator : values()) { if (!validator.isValid(event, config)) { return false; } } return areTimeZoneIdsValid(event); }
private static boolean isEventValid(VEvent event, ValidationConfig config) { if (config == null) { LOG.error("ValidationConfig cannot be null"); return false; } DtStart startDate = event.getStartDate(); DtEnd endDate = event.getEndDate(true); if (startDate == null || startDate.getDate() == null || endDate != null && startDate.getDate().after(endDate.getDate())) { return false; } for (PropertyValidator validator : values()) { if (!validator.isValid(event, config)) { return false; } } return areTimeZoneIdsValid(event); }
public void setStartDate(Date date) { DtStart dtStart = getEvent().getStartDate(); if (dtStart != null) { dtStart.setDate(date); } else { dtStart = new DtStart(date); getEvent().getProperties().add(dtStart); } setDatePropertyValue(dtStart, date); }
public void parseEvent(EventResource r, String data) throws IOException, ParserException { CalendarBuilder builder = new CalendarBuilder(); net.fortuna.ical4j.model.Calendar calendar = builder.build(new ByteArrayInputStream(data.getBytes("UTF-8"))); if (calendar == null) { return; } VEvent ev = event(calendar); if( ev == null) { return ; } String summary = null; if (ev.getSummary() != null) { summary = ev.getSummary().getValue(); } r.setSummary(summary); r.setStart(ev.getStartDate().getDate()); Date endDate = null; if (ev.getEndDate() != null) { endDate = ev.getEndDate().getDate(); } r.setEnd(endDate); }
public final void testGetConsumedTime3() throws Exception { String resource = "/samples/valid/calconnect10.ics"; net.fortuna.ical4j.model.Calendar calendar = loadCalendar(resource); VEvent vev = (VEvent) calendar.getComponent(Component.VEVENT); Date start = vev.getStartDate().getDate(); Calendar cal = getCalendarInstance(); cal.add(Calendar.YEAR, 1); Date latest = new Date(cal.getTime()); PeriodList pl = vev.getConsumedTime(start, latest); assertTrue(!pl.isEmpty()); }
/** * Get the duration for an event. If the DURATION property * exist, use that. Else, calculate duration from DTSTART and * DTEND. * @param event The event. * @return duration for event */ public static Dur getDuration(VEvent event) { Duration duration = (Duration) event.getProperties().getProperty(Property.DURATION); if (duration != null) { return duration.getDuration(); } DtStart dtstart = event.getStartDate(); if (dtstart == null) { return null; } DtEnd dtend = (DtEnd) event.getProperties().getProperty(Property.DTEND); if (dtend == null) { return null; } return new Duration(dtstart.getDate(), dtend.getDate()).getDuration(); }
/** * Convenience method to pull the DTEND out of the property list. If DTEND was not specified, use the DTSTART + * DURATION to calculate it. * @param deriveFromDuration specifies whether to derive an end date from the event duration where an end date is * not found * @return The end for this VEVENT. */ public final DtEnd getEndDate(final boolean deriveFromDuration) { DtEnd dtEnd = (DtEnd) getProperty(Property.DTEND); // No DTEND? No problem, we'll use the DURATION. if (dtEnd == null && deriveFromDuration && getDuration() != null) { final DtStart dtStart = getStartDate(); final Duration vEventDuration = getDuration(); dtEnd = new DtEnd(Dates.getInstance(vEventDuration.getDuration() .getTime(dtStart.getDate()), (Value) dtStart .getParameter(Parameter.VALUE))); if (dtStart.isUtc()) { dtEnd.setUtc(true); } } return dtEnd; }