Obtains an instance of ZoneId
from an ID ensuring that the
ID is valid and available for use.
This method parses the ID producing a ZoneId
or ZoneOffset
.
A ZoneOffset
is returned if the ID is 'Z', or starts with '+' or '-'.
The result will always be a valid ID for which ZoneRules
can be obtained.
Parsing matches the zone ID step by step as follows.
ZoneOffset.UTC
.
DateTimeException
is thrown.
ZoneOffset
using ZoneOffset.of(String)
.
ZoneId
with the same ID and rules equivalent to ZoneOffset.UTC
.
ZoneOffset
.
The result will be a ZoneId
with the specified UTC/GMT/UT prefix
and the normalized offset ID as per ZoneOffset.getId()
.
The rules of the returned ZoneId
will be equivalent to the
parsed ZoneOffset
.
[A-Za-z][A-Za-z0-9~/._+-]+
otherwise a DateTimeException
is thrown. If the zone ID is not
in the configured set of IDs, 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 java.util.TimeZone
.
zoneId | the time-zone ID, not null |
DateTimeException | if the zone ID has an invalid format | |
ZoneRulesException | if the zone ID is a region ID that cannot be found |
Diagram: Offset