@Override public VEvent createComponent(PropertyList properties, ComponentList subComponents) { return new VEvent(properties, subComponents); } }
/** * {@inheritDoc} */ public int hashCode() { return new HashCodeBuilder().append(getName()).append(getProperties()) .append(getAlarms()).toHashCode(); }
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); } });
ICalendar ical = new ICalendar(); VEvent event = new VEvent(); event.setStatus(Status.cancelled()); event.setUid(...); //the UID of the existing event event.setSequence(2); //increment the sequence number of the existing event ical.addEvent(event);
ICalendar icals = new ICalendar(); VEvent event = new VEvent(); event.setDateStart(new Date()); event.setDateEnd(new Date()); event.setDescription("some description"); icals.setProductId("some product ID"); icals.addEvent(event); WriterChainText text = Biweekly.write(icals); System.out.println(text.go());
public void validate(final VEvent target) throws ValidationException { Arrays.asList(ATTENDEE, DTSTAMP, ORGANIZER, UID).forEach(property -> PropertyValidator.getInstance().assertOne(property, target.getProperties())); Arrays.asList(RECURRENCE_ID, SEQUENCE, CATEGORIES, CLASS, CREATED, DESCRIPTION, DTEND, DTSTART, DURATION, GEO, LAST_MODIFIED, LOCATION, PRIORITY, RESOURCES, STATUS, SUMMARY, TRANSP, URL).forEach(property -> PropertyValidator.getInstance().assertOneOrLess(property, target.getProperties())); ComponentValidator.assertNone(VALARM, target.getAlarms()); } }
/** * Returns a single occurrence of a recurring event. * @param date a date on which the occurence should occur * @return a single non-recurring event instance for the specified date, or null if the event doesn't * occur on the specified date * @throws IOException where an error occurs reading data * @throws URISyntaxException where an invalid URI is encountered * @throws ParseException where an error occurs parsing data */ public final VEvent getOccurrence(final Date date) throws IOException, URISyntaxException, ParseException { final PeriodList consumedTime = getConsumedTime(date, date); for (final Period p : consumedTime) { if (p.getStart().equals(date)) { final VEvent occurrence = (VEvent) this.copy(); occurrence.getProperties().add(new RecurrenceId(date)); return occurrence; } } return null; }
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); }
@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; } }
Calendar calendar = new Calendar(); PropertyList calendarProperties = calendar.getProperties(); calendarProperties.add(Version.VERSION_2_0); calendarProperties.add(Method.REQUEST); // other properties ... VEvent vEvent = new VEvent(/*startDate, endDate*/); PropertyList vEventProperties = vEvent.getProperties(); vEventProperties.add(Priority.MEDIUM); vEventProperties.add(Clazz.PUBLIC); // other properties ... calendar.getComponents().add(vEvent); messageBodyPart.setDataHandler(new DataHandler(new ByteArrayDataSource(calendar.toString(), "text/calendar")));
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); }
/** * Test to ensure that EXDATE properties are correctly applied. * * @throws ParseException */ public void testGetConsumedTimeWithExDate() throws ParseException { VEvent event1 = new VEvent(new DateTime("20050103T080000"), java.time.Duration.ofMinutes(15), "Event 1"); Recur rRuleRecur = new Recur("FREQ=WEEKLY;INTERVAL=1;BYDAY=MO,TU,WE,TH,FR"); RRule rRule = new RRule(rRuleRecur); event1.getProperties().add(rRule); ParameterList parameterList = new ParameterList(); parameterList.add(Value.DATE); ExDate exDate = new ExDate(parameterList, "20050106"); event1.getProperties().add(exDate); Date start = new Date("20050106"); Date end = new Date("20050107"); PeriodList list = event1.getConsumedTime(start, end); assertTrue(list.isEmpty()); }
/** * 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); }
public final void test3() { java.util.Calendar cal = getCalendarInstance(); // tomorrow.. cal.add(java.util.Calendar.DAY_OF_MONTH, 1); cal.set(java.util.Calendar.HOUR_OF_DAY, 9); cal.set(java.util.Calendar.MINUTE, 30); VEvent meeting = new VEvent(new DateTime(cal.getTime().getTime()), java.time.Duration.ofHours(1), "Progress Meeting"); // add timezone information.. meeting.getProperty(Property.DTSTART).getParameters().add(tzParam); log.info(meeting.toString()); }
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); }
/** * Constructs a new VEVENT instance starting at the specified time with the specified summary. * @param start the start date of the new event * @param summary the event summary */ public VEvent(final Date start, final String summary) { this(); getProperties().add(new DtStart(start)); getProperties().add(new Summary(summary)); }
/** * @return the optional priority property for an event */ public final Priority getPriority() { return getProperty(Property.PRIORITY); }
/** * 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); }
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()); }
/** * Returns a normalised list of periods representing the consumed time for this event. * @param rangeStart the start of a range * @param rangeEnd the end of a range * @return a normalised list of periods representing consumed time for this event * @see VEvent#getConsumedTime(Date, Date, boolean) */ public final PeriodList getConsumedTime(final Date rangeStart, final Date rangeEnd) { return getConsumedTime(rangeStart, rangeEnd, true); }