/** * Determine if a Date is floating. A floating Date is a Date * instance or a DateTime that is not utc and does not have a timezone. * @param date The date. * @return true if the date is floating, otherwise false */ public static boolean isFloating(Date date) { if(date instanceof DateTime) { DateTime dt = (DateTime) date; return !dt.isUtc() && dt.getTimeZone()==null; } else { return true; } }
/** * Determine if a Date is floating. A floating Date is a Date * instance or a DateTime that is not utc and does not have a timezone. * @param date The date. * @return true if the date is floating, otherwise false */ public static boolean isFloating(Date date) { if(date instanceof DateTime) { DateTime dt = (DateTime) date; return !dt.isUtc() && dt.getTimeZone()==null; } else { return true; } }
/** * * @param dtStart The timerange start. * @param dtEnd The timerange end. */ public TimeRangeFilter(DateTime dtStart, DateTime dtEnd) { if (!dtStart.isUtc()) { throw new IllegalArgumentException("timerange start must be UTC"); } if (!dtEnd.isUtc()) { throw new IllegalArgumentException("timerange start must be UTC"); } Period period = new Period(dtStart, dtEnd); setPeriod(period); }
/** * * @param dtStart The timerange start. * @param dtEnd The timerange end. */ public TimeRangeFilter(DateTime dtStart, DateTime dtEnd) { if (!dtStart.isUtc()) { throw new IllegalArgumentException("timerange start must be UTC"); } if (!dtEnd.isUtc()) { throw new IllegalArgumentException("timerange start must be UTC"); } Period period = new Period(dtStart, dtEnd); setPeriod(period); }
/** * Indicates whether the current date value is specified in UTC time. * * @return true if the property is in UTC time, otherwise false */ public final boolean isUtc() { return getDate() instanceof DateTime && ((DateTime) getDate()).isUtc(); }
/** * Indicates whether the current date value is specified in UTC time. * * @return true if the property is in UTC time, otherwise false */ public final boolean isUtc() { return getDate() instanceof DateTime && ((DateTime) getDate()).isUtc(); }
/** * Indicates whether the current date value is specified in UTC time. * @return true if the property is in UTC time, otherwise false */ public final boolean isUtc() { if (getDate() instanceof DateTime) { return ((DateTime) getDate()).isUtc(); } return false; }
/** * Indicates whether the current date value is specified in UTC time. * * @return true if the property is in UTC time, otherwise false */ public final boolean isUtc() { return getDate() instanceof DateTime && ((DateTime) getDate()).isUtc(); }
/** * Indicates whether the current date value is specified in UTC time. * * @return true if the property is in UTC time, otherwise false */ public final boolean isUtc() { return getDate() instanceof DateTime && ((DateTime) getDate()).isUtc(); }
/** * @param date * a date-time value */ public DateTime(final java.util.Date date) { super(date.getTime(), Dates.PRECISION_SECOND, java.util.TimeZone.getDefault()); this.time = new Time(date.getTime(), getFormat().getTimeZone()); // copy timezone information if applicable.. if (date instanceof DateTime) { final DateTime dateTime = (DateTime) date; if (dateTime.isUtc()) { setUtc(true); } else { setTimeZone(dateTime.getTimeZone()); } } }
/** * */ public void testGetEndIsUtc() { assertEquals(expectedIsUtc, period.getEnd().isUtc()); }
private void normalise() { // ensure the end timezone is the same as the start.. if (getStart().isUtc()) { getEnd().setUtc(true); } else { getEnd().setTimeZone(getStart().getTimeZone()); } }
private void normalise() { // ensure the end timezone is the same as the start.. if (getStart().isUtc()) { getEnd().setUtc(true); } else { getEnd().setTimeZone(getStart().getTimeZone()); } }
private void normalise() { // ensure the end timezone is the same as the start.. if (getStart().isUtc()) { getEnd().setUtc(true); } else { getEnd().setTimeZone(getStart().getTimeZone()); } }
private void normalise() { // ensure the end timezone is the same as the start.. if (getStart().isUtc()) { getEnd().setUtc(true); } else { getEnd().setTimeZone(getStart().getTimeZone()); } }
private void normalise() { // ensure the end timezone is the same as the start.. if (getStart().isUtc()) { getEnd().setUtc(true); } else { getEnd().setTimeZone(getStart().getTimeZone()); } }
/** * {@inheritDoc} */ public void validate() throws ValidationException { super.validate(); if (getDate() != null && !(getDate() instanceof DateTime)) { throw new ValidationException( "Property must have a DATE-TIME value"); } final DateTime dateTime = (DateTime) getDate(); if (dateTime != null && !dateTime.isUtc()) { throw new ValidationException(getName() + ": DATE-TIME value must be specified in UTC time"); } } }
/** * {@inheritDoc} */ public void validate() throws ValidationException { super.validate(); if (getDate() != null && !(getDate() instanceof DateTime)) { throw new ValidationException( "Property must have a DATE-TIME value"); } final DateTime dateTime = (DateTime) getDate(); if (dateTime != null && !dateTime.isUtc()) { throw new ValidationException(getName() + ": DATE-TIME value must be specified in UTC time"); } } }
/** * {@inheritDoc} */ public void validate() throws ValidationException { super.validate(); if (getDate() != null && !(getDate() instanceof DateTime)) { throw new ValidationException( "Property must have a DATE-TIME value"); } final DateTime dateTime = (DateTime) getDate(); if (dateTime != null && !dateTime.isUtc()) { throw new ValidationException(getName() + ": DATE-TIME value must be specified in UTC time"); } } }
public void testShouldPreserveUtcTimezoneForExDate() throws Exception { CalendarBuilder builder = new CalendarBuilder(); Calendar calendar = builder.build(getClass().getResourceAsStream("/samples/valid/EXDATE-IN-UTC.ics")); Component event = calendar.getComponent(Component.VEVENT); List<ExDate> exdates = event.getProperties(Property.EXDATE); for (ExDate exDate : exdates) { for (Date dateEx : exDate.getDates()) { DateTime dateTimeEx = (DateTime) dateEx; assertNotNull(dateTimeEx); assertTrue("This exception date should be in UTC", dateTimeEx.isUtc()); } } }