protected void setDatePropertyValue(DateProperty prop, Date date) { if (prop == null) { return; } Value value = (Value) prop.getParameters().getParameter(Parameter.VALUE); if (value != null) { prop.getParameters().remove(value); } // Add VALUE=DATE for Date values, otherwise // leave out VALUE=DATE-TIME because it is redundant if(! (date instanceof DateTime)) { prop.getParameters().add(Value.DATE); } }
protected void setDatePropertyValue(DateProperty prop, Date date) { if (prop == null) { return; } Value value = (Value) prop.getParameters().getParameter(Parameter.VALUE); if (value != null) { prop.getParameters().remove(value); } // Add VALUE=DATE for Date values, otherwise // leave out VALUE=DATE-TIME because it is redundant if(! (date instanceof DateTime)) { prop.getParameters().add(Value.DATE); } }
@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); }
/** * 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); } }
@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); }
/** * 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); } }
@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); }
/** * 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)); }
/** * 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)); }
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); } } }
/** * Updates the timezone associated with the property's value. If the specified timezone is equivalent to UTC any * existing TZID parameters will be removed. Note that this method is only applicable where the current date is an * instance of <code>DateTime</code>. For all other cases an <code>UnsupportedOperationException</code> will be * thrown. * * @param timezone */ private void updateTimeZone(final TimeZone timezone) { this.timeZone = timezone; if (timezone != null) { if (getDate() != null && !(getDate() instanceof DateTime)) { throw new UnsupportedOperationException( "TimeZone is not applicable to current value"); } if (getDate() != null) { ((DateTime) getDate()).setTimeZone(timezone); } getParameters().replace(new TzId(timezone.getID())); } else { // use setUtc() to reset timezone.. setUtc(isUtc()); } }
private void initDateProp(final DateProperty dt, final TimeZoneRegistry tzreg) throws CalFacadeException { try { String tzid = getTzid(); ParameterList pl = dt.getParameters(); if (getDateType()) { pl.add(Value.DATE); } if (tzid != null) { dt.setTimeZone(tzreg.getTimeZone(tzid)); } dt.setValue(getDtval()); } catch (Throwable t) { throw new CalFacadeException(t); } }
/** * Updates the timezone associated with the property's value. If the specified timezone is equivalent to UTC any * existing TZID parameters will be removed. Note that this method is only applicable where the current date is an * instance of <code>DateTime</code>. For all other cases an <code>UnsupportedOperationException</code> will be * thrown. * * @param timezone */ private void updateTimeZone(final TimeZone timezone) { this.timeZone = timezone; if (timezone != null) { if (getDate() != null && !(getDate() instanceof DateTime)) { throw new UnsupportedOperationException( "TimeZone is not applicable to current value"); } if (getDate() != null) { ((DateTime) getDate()).setTimeZone(timezone); } getParameters().replace(new TzId(timezone.getID())); } else { // use setUtc() to reset timezone.. setUtc(isUtc()); } }