/** * Normalizes the time-zone ID, returning a {@code ZoneOffset} where possible. * <p> * The returns a normalized {@code ZoneId} that can be used in place of this ID. * The result will have {@code ZoneRules} equivalent to those returned by this object, * however the ID returned by {@code getId()} may be different. * <p> * The normalization checks if the rules of this {@code ZoneId} have a fixed offset. * If they do, then the {@code ZoneOffset} equal to that offset is returned. * Otherwise {@code this} is returned. * * @return the time-zone unique ID, not null */ public ZoneId normalized() { try { ZoneRules rules = getRules(); if (rules.isFixedOffset()) { return rules.getOffset(Instant.EPOCH); } } catch (ZoneRulesException ex) { // ignore invalid objects } return this; }
/** * Normalizes the time-zone ID, returning a {@code ZoneOffset} where possible. * <p> * The returns a normalized {@code ZoneId} that can be used in place of this ID. * The result will have {@code ZoneRules} equivalent to those returned by this object, * however the ID returned by {@code getId()} may be different. * <p> * The normalization checks if the rules of this {@code ZoneId} have a fixed offset. * If they do, then the {@code ZoneOffset} equal to that offset is returned. * Otherwise {@code this} is returned. * * @return the time-zone unique ID, not null */ public ZoneId normalized() { try { ZoneRules rules = getRules(); if (rules.isFixedOffset()) { return rules.getOffset(Instant.EPOCH); } } catch (ZoneRulesException ex) { // ignore invalid objects } return this; }