@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); }
@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); }
@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); }
setUtc(isUtc());
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); } } }
/** * @param comp The component. */ private void componentToUTC(Component comp) { // Do to each top-level property for (Property prop : (List<Property>) comp.getProperties()) { if (prop instanceof DateProperty) { DateProperty dprop = (DateProperty) prop; Date date = dprop.getDate(); if (date instanceof DateTime && (((DateTime) date).getTimeZone() != null)) { dprop.setUtc(true); } } } // Do to each embedded component ComponentList<? extends CalendarComponent> subcomps = null; if (comp instanceof VEvent) { subcomps = ((VEvent) comp).getAlarms() ; } else if (comp instanceof VToDo) { subcomps = ((VToDo)comp).getAlarms(); } if (subcomps != null) { for (CalendarComponent subcomp : subcomps) { componentToUTC(subcomp); } } }
/** * @param comp The component. */ private void componentToUTC(Component comp) { // Do to each top-level property for (Property prop : (List<Property>) comp.getProperties()) { if (prop instanceof DateProperty) { DateProperty dprop = (DateProperty) prop; Date date = dprop.getDate(); if (date instanceof DateTime && (((DateTime) date).getTimeZone() != null)) { dprop.setUtc(true); } } } // Do to each embedded component ComponentList<? extends CalendarComponent> subcomps = null; if (comp instanceof VEvent) { subcomps = ((VEvent) comp).getAlarms() ; } else if (comp instanceof VToDo) { subcomps = ((VToDo)comp).getAlarms(); } if (subcomps != null) { for (CalendarComponent subcomp : subcomps) { componentToUTC(subcomp); } } }
/** * 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()); } }
/** * 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()); } }
/** * 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()); } }
/** * 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()); } }