/** * Unit tests for timezone constructor. */ public void testDtStartTimezone() throws ParseException { DtStart dtStart = new DtStart(timezone); dtStart.setValue(new DateTime().toString()); assertEquals(timezone, dtStart.getTimeZone()); // initialising with DATE value should reset timezone.. dtStart.setDate(new Date()); assertNull(dtStart.getTimeZone()); }
protected boolean isAllDay(final VEvent vEvent) { final DtStart dtStart = vEvent.getStartDate(); return dtStart != null && dtStart.getDate() instanceof net.fortuna.ical4j.model.DateTime == false; }
String[] parts = property.split(":"); if (parts.length > 1) { try { String timezone = parts[0].replace("DTSTART;TZID=", ""); DtStart start = new DtStart(); start.getParameters().add(Value.DATE_TIME); start.getParameters().add(new TzId(timezone)); start.setValue(parts[1]); } catch (ParseException e) { e.printStackTrace(); } }
/** * Test non-utc timezone works. */ public void testNonUtcTimezone() throws ParseException { DtStart start = new DtStart(); start.getParameters().add(Value.DATE_TIME); start.getParameters().add(new TzId("GMT")); start.setValue("20070101T080000"); assertEquals("DTSTART;VALUE=DATE-TIME;TZID=GMT:20070101T080000" + Strings.LINE_SEPARATOR, start.toString()); } }
/** * 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; }
if (getDuration() != null) { vEventDuration = getDuration(); } else if (dtStart.getDate() instanceof DateTime) { 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());
/** * 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)); }
/** * */ public final void testChristmas() { // create event start date.. java.util.Calendar calendar = getCalendarInstance(); calendar.set(java.util.Calendar.MONTH, java.util.Calendar.DECEMBER); calendar.set(java.util.Calendar.DAY_OF_MONTH, 25); DtStart start = new DtStart(new Date(calendar.getTime())); start.getParameters().add(tzParam); start.getParameters().add(Value.DATE); Summary summary = new Summary("Christmas Day; \n this is a, test\\"); VEvent christmas = new VEvent(); christmas.getProperties().add(start); christmas.getProperties().add(summary); log.info(christmas.toString()); }
final String bogusTime = "T230000"; final Parameter par = dtStart.getParameter("VALUE"); final boolean isDateType = (par != null) && (par.equals(Value.DATE)); mdtStart = new DtStart(new Date(bogusDate)); } else if (dtStart.isUtc()) { mdtStart = new DtStart(bogusDate + bogusTime + "Z"); } else if (dtStart.getTimeZone() == null) { mdtStart = new DtStart(bogusDate + bogusTime); } else { mdtStart = new DtStart(bogusDate + bogusTime + "Z", dtStart.getTimeZone());
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()); }
/** * @param aList a list of parameters for this component * @param aValue a value string for this component * @throws ParseException where the specified value string is not a valid date-time/date representation */ public DtStart(final ParameterList aList, final String aValue) throws ParseException { super(DTSTART, aList, new Factory()); setValue(aValue); }
/** * Unit tests for value/timezone constructor. */ public void testDtStartStringTimezone() throws ParseException { String value = new DateTime().toString(); DtStart dtStart = new DtStart(value, timezone); assertEquals(timezone, dtStart.getTimeZone()); assertEquals(value, dtStart.getValue()); }
if (Value.DATE.equals(start.getParameter(Parameter.VALUE))) { throw new ValidationException("Property [" + Property.DTSTART + "] must be a " + Value.DATE_TIME);
public void testAmericaIndiana() { java.util.TimeZone indianaTz = java.util.TimeZone .getTimeZone("America/Indiana/Indianapolis"); Calendar cal = Calendar.getInstance(indianaTz); cal.set(Calendar.HOUR_OF_DAY, 10); cal.set(Calendar.MINUTE, 20); DateTime dtStart = new DateTime(cal.getTime()); DtStart pDtStart = new DtStart(dtStart); pDtStart.setTimeZone(registry .getTimeZone("America/Indiana/Indianapolis")); }
/** * 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 DtStart(final ParameterList aList, final Date aDate) { super(DTSTART, aList, PropertyFactoryImpl.getInstance()); setDate(aDate); }
rid = new RecurrenceId(); try { if(startDate.isUtc()){ rid.setUtc(true); }else if(startDate.getTimeZone() != null){ rid.setTimeZone(startDate.getTimeZone());