public Property createProperty(final String name, final ParameterList parameters, final String value) throws IOException, URISyntaxException, ParseException { return new DtEnd(parameters, value); }
protected static Timestamp fromDtEnd(PropertyList propertyList) { DtEnd iCalObj = (DtEnd) propertyList.getProperty(DtEnd.DTEND); if (iCalObj == null) { return null; } Date date = iCalObj.getDate(); return new Timestamp(date.getTime()); }
/** * Gets end date. * @param comp The component. * @return The date. */ private Date getEndDate(Component comp) { DtEnd dtEnd = (DtEnd) comp.getProperties().getProperty(Property.DTEND); // No DTEND? No problem, we'll use the DURATION if present. if (dtEnd == null) { Date dtStart = getStartDate(comp); Duration duration = (Duration) comp.getProperties().getProperty( Property.DURATION); if (duration != null) { dtEnd = new DtEnd(org.unitedinternet.cosmo.calendar.util.Dates.getInstance(duration.getDuration() .getTime(dtStart), dtStart)); } } return (dtEnd != null) ? dtEnd.getDate() : null; } }
/** * 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; }
DtEnd dtEnd = new DtEnd(new DateTime()); dtEnd.getParameters().replace(Value.DATE_TIME); log.info(dtEnd.toString()); suite.addTest(new DtEndTest("testValidation", dtEnd)); dtEnd = (DtEnd) dtEnd.copy(); dtEnd.getParameters().replace(Value.DATE); log.info(dtEnd.toString()); suite.addTest(new DtEndTest("testValidationException", dtEnd)); dtEnd = (DtEnd) dtEnd.copy(); dtEnd.setUtc(true); log.info(dtEnd.toString()); suite.addTest(new DtEndTest("testValidation", dtEnd)); dtEnd = (DtEnd) dtEnd.copy(); dtEnd.getParameters().replace(Value.DATE); log.info(dtEnd.toString()); suite.addTest(new DtEndTest("testValidation", dtEnd)); dtEnd = (DtEnd) dtEnd.copy(); dtEnd.setDate(new Date()); dtEnd.getParameters().remove(Value.DATE); log.info(dtEnd.toString()); suite.addTest(new DtEndTest("testValidationException", dtEnd));
dtEnd = new DtEnd(Dates.getInstance(Date.from(dtStart.getDate().toInstant().plus(vEventDuration.getDuration())), dtStart.getParameter(Parameter.VALUE))); if (dtStart.isUtc()) { dtEnd.setUtc(true); } else { dtEnd.setTimeZone(dtStart.getTimeZone());
cal.set(2005, 0, 2, 11, 59); Date end = cal.getTime(); DtEnd dtEnd = new DtEnd(new DateTime(end)); dtEnd.setTimeZone(tzreg.getTimeZone("America/Los_Angeles")); suite.addTest(new DurTest(new Dur(dtStart.getDate(), dtEnd.getDate()), "PT23H59M"));
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); }
/** * Constructor. Date or Date-Time format is determined based on the presence of a VALUE parameter. * * @param aList a list of parameters for this component * @param aDate a date */ public DtEnd(final ParameterList aList, final Date aDate) { super(DTEND, aList, new Factory()); setDate(aDate); }
/** * @param aList a list of parameters for this component * @param aValue a value string for this component * @throws ParseException when the specified string is not a valid date/date-time representation */ public DtEnd(final ParameterList aList, final String aValue) throws ParseException { super(DTEND, aList, new Factory()); setValue(aValue); }
if (Value.DATE.equals(end.getParameter(Parameter.VALUE))) { throw new ValidationException("Property [" + Property.DTEND + "] must be a " + Value.DATE_TIME);
DtEnd dtend = val.getDtend().makeDtEnd(tzreg); if (freeBusy | val.getForceUTC()) { dtend.setUtc(true);
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; }
/** * Gets end date. * * @param comp The component. * @return The date. */ private Date getEndDate(Component comp) { DtEnd dtEnd = (DtEnd) comp.getProperties().getProperty(Property.DTEND); // No DTEND? No problem, we'll use the DURATION if present. if (dtEnd == null) { Date dtStart = getStartDate(comp); Duration duration = (Duration) comp.getProperties().getProperty( Property.DURATION); if (duration != null) { dtEnd = new DtEnd(org.unitedinternet.cosmo.calendar.util.Dates.getInstance(duration.getDuration() .getTime(dtStart), dtStart)); } } return (dtEnd != null) ? dtEnd.getDate() : null; }
private BwDateTime addDuration(final Dur val) throws CalFacadeException { DtEnd dtEnd; java.util.Date endDt = val.getTime(makeDate()); DtStart dtStart = makeDtStart(Timezones.getTzRegistry()); if (getDateType()) { dtEnd = new DtEnd(new Date(endDt)); addIcalParameter(dtEnd, Value.DATE); } else { DateTime d = new DateTime(endDt); Parameter tzid = getIcalParameter(dtStart, "TZID"); if (tzid != null) { DateTime sd = (DateTime)dtStart.getDate(); d.setTimeZone(sd.getTimeZone()); } // dtEnd = new DtEnd(d, dtStart.isUtc()); dtEnd = new DtEnd(d); if (tzid != null) { addIcalParameter(dtEnd, tzid); } else if (dtStart.isUtc()) { dtEnd.setUtc(true); } } return makeBwDateTime(dtEnd); }