@Override public void applyTo(DateProperty element) { TzHelper.correctTzParameterFrom(element); if (!element.isUtc() || element.getParameter(Parameter.TZID) == null) { return; } element.getParameters().removeAll(Parameter.TZID); element.setUtc(true); }
/** * Default setValue() implementation. Allows for either DATE or DATE-TIME values. * * @param value a string representation of a DATE or DATE-TIME value * @throws ParseException where the specified value is not a valid DATE or DATE-TIME * representation */ public void setValue(final String value) throws ParseException { // value can be either a date-time or a date.. if (Value.DATE.equals(getParameter(Parameter.VALUE))) { // ensure timezone is null for VALUE=DATE properties.. updateTimeZone(null); this.date = new Date(value); } else if (value != null && !value.isEmpty()){ this.date = new DateTime(value, timeZone); } }
@Override public void applyTo(DateProperty element) { TzHelper.correctTzParameterFrom(element); if (!element.isUtc() || element.getParameter(Parameter.TZID) == null) { return; } element.getParameters().removeAll(Parameter.TZID); element.setUtc(true); }
/** * Default setValue() implementation. Allows for either DATE or DATE-TIME values. * * @param value a string representation of a DATE or DATE-TIME value * @throws ParseException where the specified value is not a valid DATE or DATE-TIME * representation */ public void setValue(final String value) throws ParseException { // value can be either a date-time or a date.. if (Value.DATE.equals(getParameter(Parameter.VALUE))) { // ensure timezone is null for VALUE=DATE properties.. updateTimeZone(null); this.date = new Date(value); } else if (value != null && !value.isEmpty()){ this.date = new DateTime(value, timeZone); } }
@Override public void applyTo(DateProperty element) { TzHelper.correctTzParameterFrom(element); if (!element.isUtc() || element.getParameter(Parameter.TZID) == null) { return; } element.getParameters().removeAll(Parameter.TZID); element.setUtc(true); }
/** * Default setValue() implementation. Allows for either DATE or DATE-TIME values. * * @param value a string representation of a DATE or DATE-TIME value * @throws ParseException where the specified value is not a valid DATE or DATE-TIME * representation */ public void setValue(final String value) throws ParseException { // value can be either a date-time or a date.. if (Value.DATE.equals(getParameter(Parameter.VALUE))) { // ensure timezone is null for VALUE=DATE properties.. updateTimeZone(null); this.date = new Date(value); } else if (value != null && !value.isEmpty()){ this.date = new DateTime(value, timeZone); } }
/** * Resets the VTIMEZONE associated with the property. If utc is true, any TZID parameters are removed and the Java * timezone is updated to UTC time. If utc is false, TZID parameters are removed and the Java timezone is set to the * default timezone (i.e. represents a "floating" local time) * @param utc a UTC value */ public final void setUtc(final boolean utc) { if (getDate() != null && (getDate() instanceof DateTime)) { ((DateTime) getDate()).setUtc(utc); } getParameters().remove(getParameter(Parameter.TZID)); }
/** * Default setValue() implementation. Allows for either DATE or DATE-TIME values. * * @param value a string representation of a DATE or DATE-TIME value * @throws ParseException where the specified value is not a valid DATE or DATE-TIME * representation */ public void setValue(final String value) throws ParseException { // value can be either a date-time or a date.. if (Value.DATE.equals(getParameter(Parameter.VALUE))) { // ensure timezone is null for VALUE=DATE properties.. updateTimeZone(null); this.date = new Date(value); } else { this.date = new DateTime(value, timeZone); } }
/** * Resets the VTIMEZONE associated with the property. If utc is true, any TZID parameters are removed and the Java * timezone is updated to UTC time. If utc is false, TZID parameters are removed and the Java timezone is set to the * default timezone (i.e. represents a "floating" local time) * * @param utc a UTC value */ public final void setUtc(final boolean utc) { if (getDate() != null && (getDate() instanceof DateTime)) { ((DateTime) getDate()).setUtc(utc); } getParameters().remove(getParameter(Parameter.TZID)); }
/** * Default setValue() implementation. Allows for either DATE or DATE-TIME values. * * @param value a string representation of a DATE or DATE-TIME value * @throws ParseException where the specified value is not a valid DATE or DATE-TIME * representation */ public void setValue(final String value) throws ParseException { // value can be either a date-time or a date.. if (Value.DATE.equals(getParameter(Parameter.VALUE))) { // ensure timezone is null for VALUE=DATE properties.. updateTimeZone(null); this.date = new Date(value); } else { this.date = new DateTime(value, timeZone); } }
/** * Resets the VTIMEZONE associated with the property. If utc is true, any TZID parameters are removed and the Java * timezone is updated to UTC time. If utc is false, TZID parameters are removed and the Java timezone is set to the * default timezone (i.e. represents a "floating" local time) * * @param utc a UTC value */ public final void setUtc(final boolean utc) { if (getDate() != null && (getDate() instanceof DateTime)) { ((DateTime) getDate()).setUtc(utc); } getParameters().remove(getParameter(Parameter.TZID)); }
/** * Resets the VTIMEZONE associated with the property. If utc is true, any TZID parameters are removed and the Java * timezone is updated to UTC time. If utc is false, TZID parameters are removed and the Java timezone is set to the * default timezone (i.e. represents a "floating" local time) * * @param utc a UTC value */ public final void setUtc(final boolean utc) { if (getDate() != null && (getDate() instanceof DateTime)) { ((DateTime) getDate()).setUtc(utc); } getParameters().remove(getParameter(Parameter.TZID)); }
/** * Resets the VTIMEZONE associated with the property. If utc is true, any TZID parameters are removed and the Java * timezone is updated to UTC time. If utc is false, TZID parameters are removed and the Java timezone is set to the * default timezone (i.e. represents a "floating" local time) * * @param utc a UTC value */ public final void setUtc(final boolean utc) { if (getDate() != null && (getDate() instanceof DateTime)) { ((DateTime) getDate()).setUtc(utc); } getParameters().remove(getParameter(Parameter.TZID)); }
/** * Sets the date value of this property. The timezone and value of this * instance will also be updated accordingly. * * @param date The date to set. */ public final void setDate(final Date date) { this.date = date; if (date instanceof DateTime) { if (Value.DATE.equals(getParameter(Parameter.VALUE))) { getParameters().replace(Value.DATE_TIME); } updateTimeZone(((DateTime) date).getTimeZone()); } else { if (date != null) { getParameters().replace(Value.DATE); } /* else { getParameters().removeAll(Parameter.VALUE); } */ // ensure timezone is null for VALUE=DATE or null properties.. updateTimeZone(null); } }
/** * Sets the date value of this property. The timezone and value of this * instance will also be updated accordingly. * * @param date The date to set. */ public final void setDate(final Date date) { this.date = date; if (date instanceof DateTime) { if (Value.DATE.equals(getParameter(Parameter.VALUE))) { getParameters().replace(Value.DATE_TIME); } updateTimeZone(((DateTime) date).getTimeZone()); } else { if (date != null) { getParameters().replace(Value.DATE); } /* else { getParameters().removeAll(Parameter.VALUE); } */ // ensure timezone is null for VALUE=DATE or null properties.. updateTimeZone(null); } }
/** * Sets the date value of this property. The timezone and value of this * instance will also be updated accordingly. * @param date The date to set. */ public final void setDate(final Date date) { this.date = date; if (date instanceof DateTime) { if (Value.DATE.equals(getParameter(Parameter.VALUE))) { getParameters().replace(Value.DATE_TIME); } updateTimeZone(((DateTime) date).getTimeZone()); } else { if (date != null) { getParameters().replace(Value.DATE); } /* else { getParameters().removeAll(Parameter.VALUE); } */ // ensure timezone is null for VALUE=DATE or null properties.. updateTimeZone(null); } }
/** * Sets the date value of this property. The timezone and value of this * instance will also be updated accordingly. * * @param date The date to set. */ public final void setDate(final Date date) { this.date = date; if (date instanceof DateTime) { if (Value.DATE.equals(getParameter(Parameter.VALUE))) { getParameters().replace(Value.DATE_TIME); } updateTimeZone(((DateTime) date).getTimeZone()); } else { if (date != null) { getParameters().replace(Value.DATE); } /* else { getParameters().removeAll(Parameter.VALUE); } */ // ensure timezone is null for VALUE=DATE or null properties.. updateTimeZone(null); } }
static void correctTzParameterFrom(DateProperty property) { if (property.getValue() != null && property.getValue().endsWith("Z")) { property.getParameters().removeAll(Parameter.TZID); return; } if (property.getParameter(Parameter.TZID) != null) { String newTimezone = getCorrectedTimezoneFromTzParameter(property); String value = property.getValue(); correctTzParameter(property, newTimezone); if (newTimezone != null) { property.setTimeZone(TIMEZONE_REGISTRY.getTimeZone(newTimezone)); try { property.setValue(value); } catch (ParseException e) { LOG.warn("Failed to reset property value", e); } } else { property.setUtc(true); } } }
static void correctTzParameterFrom(DateProperty property) { if (property.getValue() != null && property.getValue().endsWith("Z")) { property.getParameters().removeAll(Parameter.TZID); return; } if (property.getParameter(Parameter.TZID) != null) { String newTimezone = getCorrectedTimezoneFromTzParameter(property); String value = property.getValue(); correctTzParameter(property, newTimezone); if (newTimezone != null) { property.setTimeZone(TIMEZONE_REGISTRY.getTimeZone(newTimezone)); try { property.setValue(value); } catch (ParseException e) { LOG.warn("Failed to reset property value", e); } } else { property.setUtc(true); } } }
static void correctTzParameterFrom(DateProperty property) { if (property.getValue() != null && property.getValue().endsWith("Z")) { property.getParameters().removeAll(Parameter.TZID); return; } if (property.getParameter(Parameter.TZID) != null) { String newTimezone = getCorrectedTimezoneFromTzParameter(property); String value = property.getValue(); correctTzParameter(property, newTimezone); if (newTimezone != null) { property.setTimeZone(TIMEZONE_REGISTRY.getTimeZone(newTimezone)); try { property.setValue(value); } catch (ParseException e) { LOG.warn("Failed to reset property value", e); } } else { property.setUtc(true); } } }