protected static Timestamp fromDtStart(PropertyList propertyList) { DtStart iCalObj = (DtStart) propertyList.getProperty(DtStart.DTSTART); if (iCalObj == null) { return null; } Date date = iCalObj.getDate(); return new Timestamp(date.getTime()); }
protected boolean isAllDay(final VEvent vEvent) { final DtStart dtStart = vEvent.getStartDate(); return dtStart != null && dtStart.getDate() instanceof net.fortuna.ical4j.model.DateTime == false; }
/** * @param arg0 another observance instance * @return a positve value if this observance starts earlier than the other, * a negative value if it occurs later than the other, or zero if they start * at the same time */ public final int compareTo(final Observance arg0) { // TODO: sort by RDATE?? final DtStart dtStart = (DtStart) getProperty(Property.DTSTART); final DtStart dtStart0 = (DtStart) arg0.getProperty(Property.DTSTART); return dtStart.getDate().compareTo(dtStart0.getDate()); }
/** * Gets start date. * * @param comp The component. * @return The date. */ private Date getStartDate(Component comp) { DtStart prop = (DtStart) comp.getProperties().getProperty( Property.DTSTART); return (prop != null) ? prop.getDate() : null; }
public Date getStartDate() { VEvent event = getEvent(); if(event==null) { return null; } DtStart dtStart = event.getStartDate(); if (dtStart == null) { return null; } return dtStart.getDate(); }
/** * Gets start date. * @param comp The component. * @return The date. */ private Date getStartDate(Component comp) { DtStart prop = (DtStart) comp.getProperties().getProperty( Property.DTSTART); return (prop != null) ? prop.getDate() : null; }
/** * Gets start date. * * @param comp The component. * @return The date. */ private Date getStartDate(Component comp) { DtStart prop = (DtStart) comp.getProperties().getProperty( Property.DTSTART); return (prop != null) ? prop.getDate() : null; }
/** * Gets start date. * @param comp The component. * @return The date. */ private Date getStartDate(Component comp) { DtStart prop = (DtStart) comp.getProperties().getProperty( Property.DTSTART); return (prop != null) ? prop.getDate() : null; }
public Date getStartDate() { VEvent event = getEvent(); if(event==null) { return null; } DtStart dtStart = event.getStartDate(); if (dtStart == null) { return null; } return dtStart.getDate(); }
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); }
private void checkDatesForComponent(Component component){ if(component == null){ return; } Property dtStart = component.getProperty(Property.DTSTART); Property dtEnd = component.getProperty(Property.DTEND); if( dtStart instanceof DtStart && dtStart.getValue()!= null && dtEnd instanceof DtEnd && dtEnd.getValue() != null && ((DtStart)dtStart).getDate().compareTo(((DtEnd)dtEnd).getDate()) > 0 ){ throw new IllegalArgumentException("End date [" + dtEnd + " is lower than start date [" + dtStart + "]"); } }
private void checkDatesForComponent(Component component){ if(component == null){ return; } Property dtStart = component.getProperty(Property.DTSTART); Property dtEnd = component.getProperty(Property.DTEND); if( dtStart instanceof DtStart && dtStart.getValue()!= null && dtEnd instanceof DtEnd && dtEnd.getValue() != null && ((DtStart)dtStart).getDate().compareTo(((DtEnd)dtEnd).getDate()) > 0 ){ throw new IllegalArgumentException("End date [" + dtEnd + " is lower than start date [" + dtStart + "]"); } }
public void testDtStartString() throws ParseException { ParameterList params = new ParameterList(); params.add(Value.DATE); DtStart dtStart = new DtStart(params, "20060811"); Calendar calendar = Calendar.getInstance(TimeZones.getDateTimeZone()); calendar.clear(); calendar.set(2006, 7, 11); calendar.clear(Calendar.HOUR_OF_DAY); calendar.clear(Calendar.MINUTE); calendar.clear(Calendar.SECOND); calendar.clear(Calendar.MILLISECOND); assertEquals(dtStart.getDate(), calendar.getTime()); }
@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; } }
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; }