/** * {@inheritDoc} */ public final void register(final TimeZone timezone, boolean update) { if (update) { // load any available updates for the timezone.. timezones.put(timezone.getID(), new TimeZone(updateDefinition(timezone.getVTimeZone()))); } else { timezones.put(timezone.getID(), timezone); } }
/** * Reset the timezone to default. */ private void resetTimeZone() { // use GMT timezone to avoid daylight savings rules affecting floating // time values.. getFormat().setTimeZone(TimeZone.getDefault()); // getFormat().setTimeZone(TimeZone.getTimeZone(TimeZones.GMT_ID)); }
/** * Constructs a new instance based on the specified VTimeZone. * * @param vTimeZone a VTIMEZONE object instance */ public TimeZone(final VTimeZone vTimeZone) { this.vTimeZone = vTimeZone; final TzId tzId = vTimeZone.getProperty(Property.TZID); setID(tzId.getValue()); this.rawOffset = getRawOffset(vTimeZone); }
/** * {@inheritDoc} */ public final void register(final TimeZone timezone, boolean update) { if (update) { try { // load any available updates for the timezone.. timezones.put(timezone.getID(), new TimeZone(timeZoneLoader.loadVTimeZone(timezone.getID()))); } catch (IOException | ParserException | ParseException e) { Logger log = LoggerFactory.getLogger(TimeZoneRegistryImpl.class); log.warn("Error occurred loading VTimeZone", e); } } else { timezones.put(timezone.getID(), timezone); } }
@Override void mapToCard(net.fortuna.ical4j.model.Calendar cal, Object bean, PropertyDescriptor pd) { TimeZoneRegistry registry = TimeZoneRegistryFactory.getInstance().createRegistry(); String tzId = propertyAccessor.get(bean, pd.getReadMethod(), String.class); TimeZone timezone = null; if (tzId != null && tzId.length() > 0) { timezone = registry.getTimeZone(tzId); // Eg Pacific/Auckland } // TODO: do we need to use a default time zone if none given? if (timezone != null) { VTimeZone tz = timezone.getVTimeZone(); cal.getComponents().add(tz); } } }
/** * Register. * @param timezone The timezone. * @param update The boolean for update. */ // @Override public void register(TimeZone timezone, boolean update) { timezones.put(timezone.getID(), timezone); } }
/** * Return ical4j TimeZone instance for timezone id. * @param id timezone id * @return ical4j TimeZone instance */ public static net.fortuna.ical4j.model.TimeZone getTimeZone(String id) { if(!allTimezoneIds.contains(id)) { return null; } VTimeZone vtz = getVTimeZone(id); if(vtz==null) { return null; } return new net.fortuna.ical4j.model.TimeZone(vtz); }
/** * Constructs an <code>ICalDate</code> from an iCalendar date * list. Date lists cannot be anytime. * @param dates The date list. * @throws UnknownTimeZoneException - if something is wrong this exception is thrown. */ public ICalDate(DateList dates) throws UnknownTimeZoneException { value = dates.getType(); tz = dates.getTimeZone(); if (tz != null) { String origId = tz.getID(); tz = tzTranslator.translateToOlsonTz(tz); if (tz == null) { throw new UnknownTimeZoneException(origId); } String id = tz.getVTimeZone().getProperties(). getProperty(Property.TZID).getValue(); tzid = new TzId(id); } text = dates.toString(); this.dates = dates; }
TimeZone timeZone = registry.getTimeZone(TimeZone.getDefault().getID()); if (timeZone == null) { timeZone = registry.getTimeZone(DEFAULT_TIME_ZONE_IDENTIFIER); final VTimeZone vTimeZone = timeZone.getVTimeZone(); final TzId timeZoneId = vTimeZone.getTimeZoneId();
protected Object initialValue() { final DateFormat format = new SimpleDateFormat(UTC_PATTERN); format.setTimeZone(TimeZone.getTimeZone(TimeZones.UTC_ID)); format.setLenient(false); return (Object)format; } };
/** * Assert the raw offset is the same as its Java equivalent. */ public void testGetRawOffset() { assertEquals(expectedRawOffset, timezone.getRawOffset()); assertEquals(tz.getRawOffset(), timezone.getRawOffset()); }
utcTz.setID(TimeZones.UTC_ID);
private void addIcalTimezone(final Calendar cal, final String tzid, final TreeSet<String> added, final TimeZoneRegistry tzreg) throws CalFacadeException { VTimeZone vtz = null; if ((tzid == null) || ((added != null) && added.contains(tzid))) { return; } //if (debug()) { // debug("Look for timezone with id " + tzid); //} TimeZone tz = tzreg.getTimeZone(tzid); if (tz != null) { vtz = tz.getVTimeZone(); } if (vtz != null) { //if (debug()) { // debug("found timezone with id " + tzid); //} cal.getComponents().add(vtz); } else if (debug()) { debug("Didn't find timezone with id " + tzid); } if (added != null) { added.add(tzid); } }
/** * Register. * @param timezone The timezone. * @param update The boolean for update. */ // @Override public void register(TimeZone timezone, boolean update) { timezones.put(timezone.getID(), timezone); } }
/** * {@inheritDoc} */ public final void register(final TimeZone timezone, boolean update) { if (update) { try { // load any available updates for the timezone.. timezones.put(timezone.getID(), new TimeZone(timeZoneLoader.loadVTimeZone(timezone.getID()))); } catch (IOException | ParserException | ParseException e) { Logger log = LoggerFactory.getLogger(TimeZoneRegistryImpl.class); log.warn("Error occurred loading VTimeZone", e); } } else { timezones.put(timezone.getID(), timezone); } }
/** * Return ical4j TimeZone instance for timezone id. * @param id timezone id * @return ical4j TimeZone instance */ public static net.fortuna.ical4j.model.TimeZone getTimeZone(String id) { if(!allTimezoneIds.contains(id)) { return null; } VTimeZone vtz = getVTimeZone(id); if(vtz==null) { return null; } return new net.fortuna.ical4j.model.TimeZone(vtz); }
/** * Constructs an <code>ICalDate</code> from an iCalendar date * list. Date lists cannot be anytime. * @param dates The date list. * @throws UnknownTimeZoneException - if something is wrong this exception is thrown. */ public ICalDate(DateList dates) throws UnknownTimeZoneException { value = dates.getType(); tz = dates.getTimeZone(); if (tz != null) { String origId = tz.getID(); tz = tzTranslator.translateToOlsonTz(tz); if (tz == null) { throw new UnknownTimeZoneException(origId); } String id = tz.getVTimeZone().getProperties(). getProperty(Property.TZID).getValue(); tzid = new TzId(id); } text = dates.toString(); this.dates = dates; }
/** * {@inheritDoc} */ public String toString() { // if time is floating avoid daylight saving rules when generating // string representation of date.. final java.util.TimeZone timeZone = format.getTimeZone(); if (!(timeZone instanceof TimeZone)) { if (gmtFormat == null) { gmtFormat = (DateFormat) format.clone(); gmtFormat.setTimeZone(TimeZone.getTimeZone(TimeZones.GMT_ID)); } if (timeZone.inDaylightTime(this) && timeZone.inDaylightTime(new Date(getTime() - 1))) { return gmtFormat.format(new Date(getTime() + timeZone.getRawOffset() + timeZone.getDSTSavings())); // return format.format(new Date(getTime() - format.getTimeZone().getDSTSavings())); } // return gmtFormat.format(new Date(getTime() + format.getTimeZone().getOffset(getTime()))); return gmtFormat.format(new Date(getTime() + timeZone.getRawOffset())); } return format.format(this); }
/** * {@inheritDoc} */ public int getOffset(long date) { final Observance observance = vTimeZone.getApplicableObservance(new DateTime(date)); if (observance != null) { final TzOffsetTo offset = observance.getProperty(Property.TZOFFSETTO); if ((offset.getOffset().getTotalSeconds() * 1000L) < getRawOffset()) { return getRawOffset(); } else { return (int) (offset.getOffset().getTotalSeconds() * 1000L); } } return 0; }
public VEvent convertVEvent(final TeamEventDO event) { final ICalConverterStore store = ICalConverterStore.getInstance(); // create vEvent final VEvent vEvent = new VEvent(false); // set time zone if (this.timeZone != null) { final net.fortuna.ical4j.model.TimeZone timezone = TIMEZONE_REGISTRY.getTimeZone(this.timeZone.getID()); vEvent.getProperties().add(timezone.getVTimeZone().getTimeZoneId()); } for (String export : this.exportsVEvent) { VEventComponentConverter converter = store.getVEventConverter(export); if (converter == null) { log.warn(String.format("No converter found for '%s', converter is skipped", export)); continue; } converter.toVEvent(event, vEvent); } return vEvent; }