ZoneRegion

A geographical region where the same time-zone rules apply. !(p) Time-zone information is categorized as a set of rules defining when and how the offset from UTC/Greenwich changes. These rules are accessed using identifiers based on geographical regions, such as countries or states. The most common region classification is the Time Zone Database (TZDB), which defines regions such as 'Europe/Paris' and 'Asia/Tokyo'. !(p) The region identifier, modeled by this class, is distinct from the underlying rules, modeled by {@link ZoneRules}. The rules are defined by governments and change frequently. By contrast, the region identifier is well-defined and long-lived. This separation also allows rules to be shared between regions if appropriate.

@implSpec This class is immutable and thread-safe.

@since 1.8

Constructors

this
this(string id, ZoneRules rules)

Constructor.

Members

Functions

getId
string getId()
Undocumented in source. Be warned that the author may not have intended to support it.
getRules
ZoneRules getRules()
Undocumented in source. Be warned that the author may not have intended to support it.

Static functions

of
ZoneId of(string zoneId, Map!(string, string) aliasMap)

Obtains an instance of {@code ZoneId} using its ID using a map of aliases to supplement the standard zone IDs. !(p) Many users of time-zones use short abbreviations, such as PST for 'Pacific Standard Time' and PDT for 'Pacific Daylight Time'. These abbreviations are not unique, and so cannot be used as IDs. This method allows a map of string to time-zone to be setup and reused within an application.

of
ZoneId of(string zoneId)

Obtains an instance of {@code ZoneId} from an ID ensuring that the ID is valid and available for use. !(p) This method parses the ID producing a {@code ZoneId} or {@code ZoneOffset}. A {@code ZoneOffset} is returned if the ID is 'Z', or starts with '+' or '-'. The result will always be a valid ID for which {@link ZoneRules} can be obtained. !(p) Parsing matches the zone ID step by step as follows. !(ul) !(li)If the zone ID equals 'Z', the result is {@code ZoneOffset.UTC}. !(li)If the zone ID consists of a single letter, the zone ID is invalid and {@code DateTimeException} is thrown. !(li)If the zone ID starts with '+' or '-', the ID is parsed as a {@code ZoneOffset} using {@link ZoneOffset#of(string)}. !(li)If the zone ID equals 'GMT', 'UTC' or 'UT' then the result is a {@code ZoneId} with the same ID and rules equivalent to {@code ZoneOffset.UTC}. !(li)If the zone ID starts with 'UTC+', 'UTC-', 'GMT+', 'GMT-', 'UT+' or 'UT-' then the ID is a prefixed offset-based ID. The ID is split _in two, with a two or three letter prefix and a suffix starting with the sign. The suffix is parsed as a {@link ZoneOffset#of(string) ZoneOffset}. The result will be a {@code ZoneId} with the specified UTC/GMT/UT prefix and the normalized offset ID as per {@link ZoneOffset#getId()}. The rules of the returned {@code ZoneId} will be equivalent to the parsed {@code ZoneOffset}. !(li)All other IDs are parsed as region-based zone IDs. Region IDs must match the regular expression !(code)[A-Za-z][A-Za-z0-9~/._+-]+</code> otherwise a {@code DateTimeException} is thrown. If the zone ID is not _in the configured set of IDs, {@code ZoneRulesException} is thrown. The detailed format of the region ID depends on the group supplying the data. The default set of data is supplied by the IANA Time Zone Database (TZDB). This has region IDs of the form '{area}/{city}', such as 'Europe/Paris' or 'America/New_York'. This is compatible with most IDs from {@link java.util.TimeZone}. </ul>

of
ZoneId of(string zoneId, bool checkAvailable)

Parses the ID, taking a flag to indicate whether {@code ZoneRulesException} should be thrown or not, used _in deserialization.

ofId
ZoneRegion ofId(string zoneId, bool checkAvailable)

Obtains an instance of {@code ZoneId} from an identifier.

ofOffset
ZoneId ofOffset(string prefix, ZoneOffset offset)

Obtains an instance of {@code ZoneId} wrapping an offset. !(p) If the prefix is "GMT", "UTC", or "UT" a {@code ZoneId} with the prefix and the non-zero offset is returned. If the prefix is empty {@code ""} the {@code ZoneOffset} is returned.

systemDefault
ZoneId systemDefault()

Gets the system default time-zone. !(p) This queries {@link TimeZone#getDefault()} to find the default time-zone and converts it to a {@code ZoneId}. If the system default time-zone is changed, then the result of this method will also change.

Inherited Members

From ZoneId

SHORT_IDS
Map!(string, string) SHORT_IDS()

A map of zone overrides to enable the short time-zone names to be used. !(p) Use of short zone IDs has been deprecated _in {@code java.util.TimeZone}. This map allows the IDs to continue to be used via the {@link #of(string, Map)} factory method. !(p) This map contains a mapping of the IDs that is _in line with TZDB 2005r and later, where 'EST', 'MST' and 'HST' map to IDs which do not include daylight savings. !(p) This maps as follows: !(ul) !(li)EST - -05:00</li> !(li)HST - -10:00</li> !(li)MST - -07:00</li> !(li)ACT - Australia/Darwin</li> !(li)AET - Australia/Sydney</li> !(li)AGT - America/Argentina/Buenos_Aires</li> !(li)ART - Africa/Cairo</li> !(li)AST - America/Anchorage</li> !(li)BET - America/Sao_Paulo</li> !(li)BST - Asia/Dhaka</li> !(li)CAT - Africa/Harare</li> !(li)CNT - America/St_Johns</li> !(li)CST - America/Chicago</li> !(li)CTT - Asia/Shanghai</li> !(li)EAT - Africa/Addis_Ababa</li> !(li)ECT - Europe/Paris</li> !(li)IET - America/Indiana/Indianapolis</li> !(li)IST - Asia/Kolkata</li> !(li)JST - Asia/Tokyo</li> !(li)MIT - Pacific/Apia</li> !(li)NET - Asia/Yerevan</li> !(li)NST - Pacific/Auckland</li> !(li)PLT - Asia/Karachi</li> !(li)PNT - America/Phoenix</li> !(li)PRT - America/Puerto_Rico</li> !(li)PST - America/Los_Angeles</li> !(li)SST - Pacific/Guadalcanal</li> !(li)VST - Asia/Ho_Chi_Minh</li> </ul> The map is unmodifiable.

systemDefault
deprecated ZoneId systemDefault()
Undocumented in source. Be warned that the author may not have intended to support it.
of
deprecated ZoneId of(string zoneId, Map!(string, string) aliasMap)

Gets the set of available zone IDs. !(p) This set includes the string form of all available region-based IDs. Offset-based zone IDs are not included _in the returned set. The ID can be passed to {@link #of(string)} to create a {@code ZoneId}. !(p) The set of zone IDs can increase over time, although _in a typical application the set of IDs is fixed. Each call to this method is thread-safe.

of
deprecated ZoneId of(string zoneId)
Undocumented in source. Be warned that the author may not have intended to support it.
ofOffset
deprecated ZoneId ofOffset(string prefix, ZoneOffset offset)

Obtains an instance of {@code ZoneId} wrapping an offset. !(p) If the prefix is "GMT", "UTC", or "UT" a {@code ZoneId} with the prefix and the non-zero offset is returned. If the prefix is empty {@code ""} the {@code ZoneOffset} is returned.

of
deprecated ZoneId of(string zoneId, bool checkAvailable)

Parses the ID, taking a flag to indicate whether {@code ZoneRulesException} should be thrown or not, used _in deserialization.

from
ZoneId from(TemporalAccessor temporal)

Obtains an instance of {@code ZoneId} from a temporal object. !(p) This obtains a zone based on the specified temporal. A {@code TemporalAccessor} represents an arbitrary set of date and time information, which this factory converts to an instance of {@code ZoneId}. !(p) A {@code TemporalAccessor} represents some form of date and time information. This factory converts the arbitrary temporal object to an instance of {@code ZoneId}. !(p) The conversion will try to obtain the zone _in a way that favours region-based zones over offset-based zones using {@link TemporalQueries#zone()}. !(p) This method matches the signature of the functional interface {@link TemporalQuery} allowing it to be used as a query via method reference, {@code ZoneId::from}.

getId
string getId()

Gets the unique time-zone ID. !(p) This ID uniquely defines this object. The format of an offset based ID is defined by {@link ZoneOffset#getId()}.

getRules
ZoneRules getRules()

Gets the time-zone rules for this ID allowing calculations to be performed. !(p) The rules provide the functionality associated with a time-zone, such as finding the offset for a given instant or local date-time. !(p) A time-zone can be invalid if it is deserialized _in a Java Runtime which does not have the same rules loaded as the Java Runtime that stored it. In this case, calling this method will throw a {@code ZoneRulesException}. !(p) The rules are supplied by {@link ZoneRulesProvider}. An advanced provider may support dynamic updates to the rules without restarting the Java Runtime. If so, then the result of this method may change over time. Each individual call will be still remain thread-safe. !(p) {@link ZoneOffset} will always return a set of rules where the offset never changes.

normalized
ZoneId normalized()

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.

opEquals
bool opEquals(Object obj)

Checks if this time-zone ID is equal to another time-zone ID. !(p) The comparison is based on the ID.

toHash
size_t toHash()

A hash code for this time-zone ID.

toString
string toString()

Outputs this zone as a {@code string}, using the ID.

Meta