/** * Returns the end date of this event. Where an end date is not available it will be derived from the event * duration. * @return a DtEnd instance, or null if one cannot be derived */ public final DtEnd getEndDate() { return getEndDate(true); }
/** * Returns the end date of this event. Where an end date is not available it will be derived from the event * duration. * @return a DtEnd instance, or null if one cannot be derived */ public final DtEnd getEndDate() { return getEndDate(true); }
/** * Returns the end date of this event. Where an end date is not available it will be derived from the event * duration. * @return a DtEnd instance, or null if one cannot be derived */ public final DtEnd getEndDate() { return getEndDate(true); }
/** * Returns the end date of this event. Where an end date is not available it will be derived from the event * duration. * @return a DtEnd instance, or null if one cannot be derived */ public final DtEnd getEndDate() { return getEndDate(true); }
/** * Returns the end date of this event. Where an end date is not available it will be derived from the event * duration. * @return a DtEnd instance, or null if one cannot be derived */ public final DtEnd getEndDate() { return getEndDate(true); }
@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.getEndDate()); } else { VFreeBusy fb = freeBusy(cal); if (fb != null) { dt = getDateValue(fb.getEndDate()); } } propertyAccessor.set(bean, pd.getWriteMethod(), dt); }
@Override public boolean fromVEvent(final TeamEventDO event, final VEvent vEvent) { final boolean isAllDay = this.isAllDay(vEvent); if (vEvent.getProperties().getProperties(Property.DTEND).isEmpty()) { return false; } if (isAllDay) { // TODO sn change behaviour to iCal standard final org.joda.time.DateTime jodaTime = new org.joda.time.DateTime(vEvent.getEndDate().getDate()); final net.fortuna.ical4j.model.Date fortunaEndDate = new net.fortuna.ical4j.model.Date(jodaTime.plusDays(-1).toDate()); event.setEndDate(new Timestamp(fortunaEndDate.getTime())); } else { event.setEndDate(ICal4JUtils.getSqlTimestamp(vEvent.getEndDate().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; }
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 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); }
/** * A test to confirm that the end date is calculated correctly * from a given start date and duration. */ public final void testEventEndDate() { Calendar cal = getCalendarInstance(); Date startDate = new Date(cal.getTime()); log.info("Start date: " + startDate); VEvent event = new VEvent(startDate, java.time.Duration.ofDays(3), "3 day event"); Date endDate = event.getEndDate().getDate(); log.info("End date: " + endDate); cal.add(Calendar.DAY_OF_YEAR, 3); assertEquals(new Date(cal.getTime()), endDate); }
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 Date getEndDate() { VEvent event = getEvent(); if(event==null) { return null; } DtEnd dtEnd = event.getEndDate(false); // if no DTEND, then calculate endDate from DURATION if (dtEnd == null) { Date startDate = getStartDate(); Dur duration = getDuration(); // if no DURATION, then there is no end time if(duration==null) { return null; } Date endDate = null; if(startDate instanceof DateTime) { endDate = new DateTime(startDate); } else { endDate = new Date(startDate); } endDate.setTime(duration.getTime(startDate).getTime()); return endDate; } return dtEnd.getDate(); }
public Date getEndDate() { VEvent event = getEvent(); if(event==null) { return null; } DtEnd dtEnd = event.getEndDate(false); // if no DTEND, then calculate endDate from DURATION if (dtEnd == null) { Date startDate = getStartDate(); Dur duration = getDuration(); // if no DURATION, then there is no end time if(duration==null) { return null; } Date endDate = null; if(startDate instanceof DateTime) { endDate = new DateTime(startDate); } else { endDate = new Date(startDate); } endDate.setTime(duration.getTime(startDate).getTime()); return endDate; } return dtEnd.getDate(); }
private static VEvent convertEventBean(EventBean event) { Date begin; Date end; if (event.isAllDay()) { begin = new Date(event.getBegin().toCalendar(new Locale("pt")).getTime()); end = new Date(event.getEnd().toCalendar(new Locale("pt")).getTime()); } else { begin = new DateTime(event.getBegin().toCalendar(new Locale("pt")).getTime()); end = new DateTime(event.getEnd().toCalendar(new Locale("pt")).getTime()); } VEvent vEvent = new VEvent(begin, end, event.getTitle()); vEvent.getStartDate().setTimeZone(TIMEZONE); vEvent.getEndDate().setTimeZone(TIMEZONE); if (event.getLocation() != null) { vEvent.getProperties().add(new Location(event.getLocation())); } if (event.getUrl() != null) { try { vEvent.getProperties().add(new Url(new URI(event.getUrl()))); } catch (URISyntaxException e) { } } if (event.getNote() != null) { vEvent.getProperties().add(new Description(event.getNote())); } Uid uid = new Uid(digest(event.getTitle() + "-" + begin.toGMTString() + "-" + end.toGMTString())); vEvent.getProperties().add(uid); return vEvent; }
/** * A test to confirm that the end date is calculated correctly * from a given start date and duration, even when timezone is specified. */ public final void testEventEndDateWithTimeZone() throws ParseException { TimeZone timezone = new TimeZoneRegistryImpl().getTimeZone("Asia/Seoul"); DateTime startDateTime = new DateTime("20181003T130000", timezone); log.info("Start date: " + startDateTime); VEvent event = new VEvent(startDateTime, java.time.Duration.ofHours(1), "1 hour event"); assertEquals(new DateTime("20181003T140000", timezone), event.getEndDate().getDate()); }
DtEnd dtend = event.getEndDate(); if (dtend != null) { event.getProperties().remove(dtend);
public void setEndDate(Date date) { DtEnd dtEnd = getEvent().getEndDate(false); if (dtEnd != null && date != null) { dtEnd.setDate(date); } else if(dtEnd !=null && date == null) { // remove DtEnd if there is no end date getEvent().getProperties().remove(dtEnd); } else { // remove the duration if there was one Duration duration = (Duration) getEvent().getProperties(). getProperty(Property.DURATION); if (duration != null) { getEvent().getProperties().remove(duration); } dtEnd = new DtEnd(date); getEvent().getProperties().add(dtEnd); } setDatePropertyValue(dtEnd, date); }
public void setEndDate(Date date) { DtEnd dtEnd = getEvent().getEndDate(false); if (dtEnd != null && date != null) { dtEnd.setDate(date); } else if(dtEnd !=null && date == null) { // remove DtEnd if there is no end date getEvent().getProperties().remove(dtEnd); } else { // remove the duration if there was one Duration duration = (Duration) getEvent().getProperties(). getProperty(Property.DURATION); if (duration != null) { getEvent().getProperties().remove(duration); } dtEnd = new DtEnd(date); getEvent().getProperties().add(dtEnd); } setDatePropertyValue(dtEnd, date); }