@Override public ZoneRules getRules() { // additional query for group provider when null allows for possibility // that the provider was added after the ZoneId was created return (rules != null ? rules : ZoneRulesProvider.getRules(id, false)); }
@Override public ZoneRules getRules() { // additional query for group provider when null allows for possibility // that the provider was added after the ZoneId was created return (rules != null ? rules : ZoneRulesProvider.getRules(id, false)); }
private SortedMap<String, ZoneRules> generateZones(String... zoneIds) throws IOException { SortedMap<String, ZoneRules> zones = new TreeMap<>(); for (String zoneId : zoneIds) { zones.put(zoneId, ZoneRulesProvider.getRules(zoneId, false)); } zoneWriter.writeZones(zones); return zones; }
/** * Obtains an instance of {@code ZoneId} from an identifier. * * @param zoneId the time-zone ID, not null * @param checkAvailable whether to check if the zone ID is available * @return the zone ID, not null * @throws DateTimeException if the ID format is invalid * @throws DateTimeException if checking availability and the ID cannot be found */ static ZoneRegion ofId(String zoneId, boolean checkAvailable) { Jdk8Methods.requireNonNull(zoneId, "zoneId"); if (zoneId.length() < 2 || PATTERN.matcher(zoneId).matches() == false) { throw new DateTimeException("Invalid ID for region-based ZoneId, invalid format: " + zoneId); } ZoneRules rules = null; try { // always attempt load for better behavior after deserialization rules = ZoneRulesProvider.getRules(zoneId, true); } catch (ZoneRulesException ex) { // special case as removed from data file if (zoneId.equals("GMT0")) { rules = ZoneOffset.UTC.getRules(); } else if (checkAvailable) { throw ex; } } return new ZoneRegion(zoneId, rules); }
/** * Obtains an instance of {@code ZoneId} from an identifier. * * @param zoneId the time-zone ID, not null * @param checkAvailable whether to check if the zone ID is available * @return the zone ID, not null * @throws DateTimeException if the ID format is invalid * @throws DateTimeException if checking availability and the ID cannot be found */ static ZoneRegion ofId(String zoneId, boolean checkAvailable) { Jdk8Methods.requireNonNull(zoneId, "zoneId"); if (zoneId.length() < 2 || PATTERN.matcher(zoneId).matches() == false) { throw new DateTimeException("Invalid ID for region-based ZoneId, invalid format: " + zoneId); } ZoneRules rules = null; try { // always attempt load for better behavior after deserialization rules = ZoneRulesProvider.getRules(zoneId, true); } catch (ZoneRulesException ex) { // special case as removed from data file if (zoneId.equals("GMT0")) { rules = ZoneOffset.UTC.getRules(); } else if (checkAvailable) { throw ex; } } return new ZoneRegion(zoneId, rules); }
/** * Call on background thread to eagerly load all zones. Starts with loading * {@link ZoneId#systemDefault()} which is the one most likely to be used. */ @WorkerThread public static void cacheZones() { ZoneId.systemDefault().getRules(); for (String zoneId : ZoneRulesProvider.getAvailableZoneIds()) { ZoneRulesProvider.getRules(zoneId, true); } }