Top Description Fields Constructors Methods
java.time

pack-priv final Class ZoneRegion

extends ZoneId
implements Serializable
Class Inheritance
All Implemented Interfaces
java.io.Serializable
Imports
java.io.DataInput, .DataOutput, .IOException, .InvalidObjectException, .ObjectInputStream, .Serializable, java.time.zone.ZoneRules, .ZoneRulesException, .ZoneRulesProvider, java.util.Objects

A geographical region where the same time-zone rules apply.

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.

Since
1.8

Field Summary

Modifier and TypeField 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
Inherited from java.time.ZoneId:
SHORT_IDS

Constructor Summary

AccessConstructor and Description
pack-priv
ZoneRegion(String
the time-zone ID, not null
id
,
ZoneRules
the rules, null for lazy lookup
rules
)

Constructor.

Method Summary

Modifier and TypeMethod and Description
private static void
checkName(String
the time-zone ID, not null
zoneId
)

Checks that the given string is a legal ZondId name.

public String
getId()

Implements abstract java.time.ZoneId.getId.

Gets the unique time-zone ID.

This ID uniquely defines this object.

pack-priv ZoneOffset
getOffset(long epochSecond)

Implements abstract java.time.ZoneId.getOffset.

Get the effective offset for an instant at the given epochSecond.

public ZoneRules
getRules()

Implements abstract java.time.ZoneId.getRules.

Gets the time-zone rules for this ID allowing calculations to be performed.

pack-priv static ZoneRegion

Returns:

the zone ID, not null
ofId
(String
the time-zone ID, not null
zoneId
,
boolean
whether to check if the zone ID is available
checkAvailable
)

Obtains an instance of ZoneId from an identifier.

pack-priv static ZoneId
private void
readObject(ObjectInputStream
the stream to read
s
)

Hides java.time.ZoneId.readObject.

Defend against malicious streams.

pack-priv void
write(DataOutput out)

Implements abstract java.time.ZoneId.write.

pack-priv void
private Object

Returns:

the instance of Ser, not null
writeReplace
()

Hides java.time.ZoneId.writeReplace.

Writes the object using a dedicated serialized form.

Inherited from java.time.ZoneId:
equalsfromgetAvailableZoneIdsgetDisplayNamehashCodenormalizedofofofofOffsetsystemDefaulttoString

Field Detail

idback to summary
private final String id

The time-zone ID, not null.

rulesback to summary
private final transient ZoneRules rules

The time-zone rules, null if zone ID was loaded leniently.

serialVersionUIDback to summary
private static final long serialVersionUID

Hides java.time.ZoneId.serialVersionUID.

Serialization version.

Annotations
@Serial

Constructor Detail

ZoneRegionback to summary
pack-priv ZoneRegion(String id, ZoneRules rules)

Constructor.

Parameters
id:String

the time-zone ID, not null

rules:ZoneRules

the rules, null for lazy lookup

Method Detail

checkNameback to summary
private static void checkName(String zoneId)

Checks that the given string is a legal ZondId name.

Parameters
zoneId:String

the time-zone ID, not null

Exceptions
DateTimeException:
if the ID format is invalid
getIdback to summary
public String getId()

Implements abstract java.time.ZoneId.getId.

Doc from java.time.ZoneId.getId.

Gets the unique time-zone ID.

This ID uniquely defines this object. The format of an offset based ID is defined by ZoneOffset#getId().

Returns:String

the time-zone unique ID, not null

Annotations
@Override
getOffsetback to summary
pack-priv ZoneOffset getOffset(long epochSecond)

Implements abstract java.time.ZoneId.getOffset.

Doc from java.time.ZoneId.getOffset.

Get the effective offset for an instant at the given epochSecond.

Annotations
@Override
getRulesback to summary
public ZoneRules getRules()

Implements abstract java.time.ZoneId.getRules.

Doc from java.time.ZoneId.getRules.

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 ZoneRulesException.

The rules are supplied by 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.

ZoneOffset will always return a set of rules where the offset never changes.

Returns:ZoneRules

the rules, not null

Annotations
@Override
ofIdback to summary
pack-priv static ZoneRegion ofId(String zoneId, boolean checkAvailable)

Obtains an instance of ZoneId from an identifier.

Parameters
zoneId:String

the time-zone ID, not null

checkAvailable:boolean

whether to check if the zone ID is available

Returns:ZoneRegion

the zone ID, not null

Exceptions
DateTimeException:
if the ID format is invalid
ZoneRulesException:
if checking availability and the ID cannot be found
readExternalback to summary
pack-priv static ZoneId readExternal(DataInput in) throws IOException
readObjectback to summary
private void readObject(ObjectInputStream s) throws InvalidObjectException

Hides java.time.ZoneId.readObject.

Defend against malicious streams.

Parameters
s:ObjectInputStream

the stream to read

Annotations
@Serial
Exceptions
InvalidObjectException:
always
writeback to summary
pack-priv void write(DataOutput out) throws IOException

Implements abstract java.time.ZoneId.write.

Annotations
@Override
writeExternalback to summary
pack-priv void writeExternal(DataOutput out) throws IOException
writeReplaceback to summary
private Object writeReplace()

Hides java.time.ZoneId.writeReplace.

Writes the object using a dedicated serialized form.

Returns:Object

the instance of Ser, not null

Annotations
@Serial
Serial data
 out.writeByte(7);  // identifies a ZoneId (not ZoneOffset)
 out.writeUTF(zoneId);