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'.
The region identifier, modeled by this class, is distinct from the
underlying rules, modeled by 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.
Implementation Specification
This class is immutable and thread-safe.
Modifier and Type | Field and Description |
---|---|
private final String | id
The time-zone ID, not null. |
private final transient ZoneRules | rules
The time-zone rules, null if zone ID was loaded leniently. |
private static final long | serialVersionUID
Serialization version.
|
Access | Constructor and Description |
---|---|
pack-priv | ZoneRegion(String
the time-zone ID, not null id, ZoneRules the rules, null for lazy lookup rules)Constructor. |
Modifier and Type | Method and Description |
---|---|
private static void | |
public String | getId()
Implements abstract java. Gets the unique time-zone ID. This ID uniquely defines this object. |
pack-priv ZoneOffset | getOffset(long epochSecond)
Implements abstract java. Get the effective offset for an instant at the given epochSecond. |
public ZoneRules | getRules()
Implements abstract java. Gets the time-zone rules for this ID allowing calculations to be performed. |
pack-priv static ZoneRegion | |
pack-priv static ZoneId | |
private void | readObject(ObjectInputStream
the stream to read s)Hides java. Defend against malicious streams. |
pack-priv void | |
pack-priv void | |
private Object | Returns: the instance ofSer , not nullHides java. Writes the object using a dedicated serialized form. |
id | back to summary |
---|---|
private final String id The time-zone ID, not null. |
rules | back to summary |
---|---|
private final transient ZoneRules rules The time-zone rules, null if zone ID was loaded leniently. |
serialVersionUID | back to summary |
---|---|
private static final long serialVersionUID Hides java. Serialization version. |
ZoneRegion | back to summary |
---|---|
pack-priv ZoneRegion(String id, ZoneRules rules) Constructor. |
checkName | back to summary |
---|---|
private static void checkName(String zoneId) Checks that the given string is a legal ZondId name.
|
getId | back to summary |
---|---|
public String getId() Implements abstract java. Doc from java. Gets the unique time-zone ID.
This ID uniquely defines this object.
The format of an offset based ID is defined by |
getOffset | back to summary |
---|---|
pack-priv ZoneOffset getOffset(long epochSecond) Implements abstract java. Doc from java. Get the effective offset for an instant at the given epochSecond.
|
getRules | back to summary |
---|---|
public ZoneRules getRules() Implements abstract java. Doc from java. Gets the time-zone rules for this ID allowing calculations to be performed. The rules provide the functionality associated with a time-zone, such as finding the offset for a given instant or local date-time.
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
The rules are supplied by
|
ofId | back to summary |
---|---|
pack-priv static ZoneRegion ofId(String zoneId, boolean checkAvailable) Obtains an instance of
|
readExternal | back to summary |
---|---|
pack-priv static ZoneId readExternal(DataInput in) throws IOException |
readObject | back to summary |
---|---|
private void readObject(ObjectInputStream s) throws InvalidObjectException Hides java. Defend against malicious streams.
|
write | back to summary |
---|---|
pack-priv void write(DataOutput out) throws IOException Implements abstract java.
|
writeExternal | back to summary |
---|---|
pack-priv void writeExternal(DataOutput out) throws IOException |
writeReplace | back to summary |
---|---|
private Object writeReplace() Hides java. Writes the object using a dedicated serialized form. |