/** * Loads an existing VTimeZone from the classpath corresponding to the specified Java timezone. * * @throws ParseException */ public VTimeZone loadVTimeZone(String id) throws IOException, ParserException, ParseException { Validate.notBlank(id, "Invalid TimeZone ID: [%s]", id); if (!cache.containsId(id)) { final URL resource = ResourceLoader.getResource(resourcePrefix + id + ".ics"); if (resource != null) { try (InputStream in = resource.openStream()) { final CalendarBuilder builder = new CalendarBuilder(); final Calendar calendar = builder.build(in); final VTimeZone vTimeZone = (VTimeZone) calendar.getComponent(Component.VTIMEZONE); // load any available updates for the timezone.. can be explicility disabled via configuration if (!"false".equals(Configurator.getProperty(UPDATE_ENABLED).orElse("true"))) { return updateDefinition(vTimeZone); } if (vTimeZone != null) { cache.putIfAbsent(id, vTimeZone); } } } else { return generateTimezoneForId(id); } } return cache.getTimezone(id); }
/** * Loads an existing VTimeZone from the classpath corresponding to the specified Java timezone. * * @throws ParseException */ public VTimeZone loadVTimeZone(String id) throws IOException, ParserException, ParseException { Validate.notBlank(id, "Invalid TimeZone ID: [%s]", id); if (!cache.containsId(id)) { final URL resource = ResourceLoader.getResource(resourcePrefix + id + ".ics"); if (resource != null) { try (InputStream in = resource.openStream()) { final CalendarBuilder builder = new CalendarBuilder(); final Calendar calendar = builder.build(in); final VTimeZone vTimeZone = (VTimeZone) calendar.getComponent(Component.VTIMEZONE); // load any available updates for the timezone.. can be explicility disabled via configuration if (!"false".equals(Configurator.getProperty(UPDATE_ENABLED).orElse("true"))) { return updateDefinition(vTimeZone); } if (vTimeZone != null) { cache.putIfAbsent(id, vTimeZone); } } } else { return generateTimezoneForId(id); } } return cache.getTimezone(id); }