Class TimeZone.ID
- All Implemented Interfaces:
Serializable
,Calendrical
- Enclosing class:
TimeZone
-
Nested Class Summary
Nested classes/interfaces inherited from class javax.time.calendar.TimeZone
TimeZone.Fixed, TimeZone.ID, TimeZone.Rule
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final String
The time-zone group ID, not null.private final String
The time-zone region ID, not null.private static final long
A serialization identifier for this class.private final String
The time-zone version ID, not null.Fields inherited from class javax.time.calendar.TimeZone
OLD_IDS_POST_2005, OLD_IDS_PRE_2005, UTC
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiongetGroup()
Finds the zone rules group for the stored group ID, such as 'TZDB'.Gets the time-zone rules group ID, such as 'TZDB'.getID()
Gets the unique time-zone ID.Gets the time-zone region identifier, such as 'Europe/London'.getRules()
Gets the time-zone rules allowing calculations to be performed.getRulesValidFor
(OffsetDateTime dateTime) Gets the time-zone rules allowing calculations to be performed, ensuring that the date-time and offset specified is valid for the returned rules.Gets the time-zone rules group version, such as '2009b'.boolean
isFixed()
Checks of the time-zone is fixed, such that the offset never varies.boolean
Checks if the version is the latest version.boolean
isValid()
Checks if this time-zone is valid such that rules can be obtained for it.boolean
isValidFor
(OffsetDateTime dateTime) Checks if this time-zone is valid such that rules can be obtained for it which are valid for the specified date-time and offset.private void
Validate deserialization.Returns a copy of this time-zone with a floating version.Returns a copy of this time-zone with the latest available version ID.withLatestVersionValidFor
(OffsetDateTime dateTime) Returns a copy of this time-zone with the latest version that is valid for the specified date-time and offset.withVersion
(String versionID) Returns a copy of this time-zone with the specified version ID.Methods inherited from class javax.time.calendar.TimeZone
equals, get, getName, getShortName, hashCode, isFloatingVersion, of, of, of, ofUnchecked, rule, toString
-
Field Details
-
serialVersionUID
private static final long serialVersionUIDA serialization identifier for this class.- See Also:
-
groupID
The time-zone group ID, not null. -
regionID
The time-zone region ID, not null. -
versionID
The time-zone version ID, not null.
-
-
Constructor Details
-
ID
Constructor.- Parameters:
groupID
- the time-zone rules group ID, not nullregionID
- the time-zone region ID, not nullversionID
- the time-zone rules version ID, not null
-
-
Method Details
-
readObject
Validate deserialization.- Parameters:
in
- the input stream- Throws:
IOException
ClassNotFoundException
-
getID
Description copied from class:TimeZone
Gets the unique time-zone ID.The unique key is created from the group ID, version ID and region ID. The format is {groupID}:{regionID}#{versionID}. If the group is 'TZDB' then the {groupID}: is omitted. If the version is floating, then the #{versionID} is omitted. Fixed time-zones will only output the region ID.
-
getGroupID
Description copied from class:TimeZone
Gets the time-zone rules group ID, such as 'TZDB'.The group ID is the first part of the
full unique ID
. Time zone rule data is supplied by a group, typically a company or organization. The default group is 'TZDB' representing the public time-zone database.For fixed time-zones, the group ID will be an empty string.
- Specified by:
getGroupID
in classTimeZone
- Returns:
- the time-zone rules group ID, never null
-
getRegionID
Description copied from class:TimeZone
Gets the time-zone region identifier, such as 'Europe/London'.The region ID is the second part of the
full unique ID
. Time zone rules are defined for a region and this element represents that region. The ID uses a format specific to the group. The default 'TZDB' group generally uses the format {area}/{city}, such as 'Europe/Paris'.- Specified by:
getRegionID
in classTimeZone
- Returns:
- the time-zone rules region ID, never null
-
getVersionID
Description copied from class:TimeZone
Gets the time-zone rules group version, such as '2009b'.The version ID is the third part of the
full unique ID
. Time zone rules change over time as governments change the associated laws. The time-zone groups capture these changes by issuing multiple versions of the data. An application can reference the exact set of rules used by using the group ID and version. Once loaded, there is no way to unload a version of the rules, however new versions may be added.The version can be an empty string which represents the floating version. This always uses the latest version of the rules available.
For fixed time-zones, the version ID will be an empty string.
- Specified by:
getVersionID
in classTimeZone
- Returns:
- the time-zone rules version ID, empty if the version is floating, never null
-
isFixed
public boolean isFixed()Description copied from class:TimeZone
Checks of the time-zone is fixed, such that the offset never varies.It is intended that
OffsetDateTime
,OffsetDate
andOffsetTime
are used in preference to fixed offset time-zones inZonedDateTime
. -
withFloatingVersion
Description copied from class:TimeZone
Returns a copy of this time-zone with a floating version.For group based time-zones, this returns a
TimeZone
with the same group and region, but a floating version. The group and region IDs are not validated.For fixed time-zones,
this
is returned.- Specified by:
withFloatingVersion
in classTimeZone
- Returns:
- the new updated time-zone, never null
-
isLatestVersion
public boolean isLatestVersion()Description copied from class:TimeZone
Checks if the version is the latest version.For floating group based time-zones, true is returned.
For non-floating group based time-zones, this returns true if the version stored is the same as the latest version available for the group and region. The group and region IDs are validated in order to calculate the latest version.
For fixed time-zones, true is returned.
- Specified by:
isLatestVersion
in classTimeZone
- Returns:
- true if the version is the latest available
-
withLatestVersion
Description copied from class:TimeZone
Returns a copy of this time-zone with the latest available version ID.For floating and non-floating group based time-zones, this returns a zone with the same group and region, but the latest version that has been registered. The group and region IDs are validated in order to calculate the latest version.
For fixed time-zones,
this
is returned.- Specified by:
withLatestVersion
in classTimeZone
- Returns:
- the new updated time-zone, never null
-
withVersion
Description copied from class:TimeZone
Returns a copy of this time-zone with the specified version ID.For group based time-zones, this returns a
TimeZone
with the same group and region, but the specified version. The group and region IDs are validated to ensure that the version is valid.For fixed time-zones, the version must be an empty string, otherwise an exception is thrown.
- Specified by:
withVersion
in classTimeZone
- Parameters:
versionID
- the version ID to use, empty means floating version, not null- Returns:
- the new updated time-zone, never null
-
withLatestVersionValidFor
Description copied from class:TimeZone
Returns a copy of this time-zone with the latest version that is valid for the specified date-time and offset.This will search for a version of the time-zone rules that would make the specified date-time valid. This is needed for cases where the time-zone changes and you hold a reference to a date-time created before the rules changed.
This method validates the group and region IDs.
- Specified by:
withLatestVersionValidFor
in classTimeZone
- Parameters:
dateTime
- the date-time to get the latest version for- Returns:
- the new updated time-zone, never null
-
getGroup
Description copied from class:TimeZone
Finds the zone rules group for the stored group ID, such as 'TZDB'.Time zone rules are provided by groups referenced by an ID.
Fixed time-zones are not provided by a group, thus this method throws an exception if the time-zone is fixed.
Callers of this method need to be aware of an unusual scenario. It is possible to obtain a
TimeZone
instance even when the rules are not available. This typically occurs when aTimeZone
is loaded from a previously stored version but the rules are not available. In this case, theTimeZone
instance is still valid, as is any associated object, such asZonedDateTime
. It is impossible to perform any calculations that require the rules however, and this method will throw an exception. -
isValid
public boolean isValid()Description copied from class:TimeZone
Checks if this time-zone is valid such that rules can be obtained for it.This will return true if the rules are available for the group, region and version ID combination. If this method returns true, then
TimeZone.getRules()
will return a valid rules instance.A time-zone can be invalid if it is deserialized in a JVM which does not have the same rules loaded as the JVM that stored it.
If this object declares a floating version of the rules and a background thread is used to update the available rules, then the result of calling this method may vary over time. Each individual call will be still remain thread-safe.
If this is a fixed time-zone, then it is always valid.
-
getRules
Description copied from class:TimeZone
Gets the time-zone rules 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. Different rules may be returned depending on the group, version and zone.
If this object declares a specific version of the rules, then the result will be of that version. If this object declares a floating version of the rules, then the latest version available will be returned.
A time-zone can be invalid if it is deserialized in a JVM which does not have the same rules loaded as the JVM that stored it. In this case, calling this method will throw an exception.
If this object declares a floating version of the rules and a background thread is used to update the available rules, then the result of calling this method may vary over time. Each individual call will be still remain thread-safe.
-
isValidFor
Description copied from class:TimeZone
Checks if this time-zone is valid such that rules can be obtained for it which are valid for the specified date-time and offset.This will return true if the rules are available for the group, region and version ID combination that are valid for the specified date-time. If this method returns true, then
TimeZone.getRulesValidFor(OffsetDateTime)
will return a valid rules instance.A time-zone can be invalid if it is deserialized in a JVM which does not have the same rules loaded as the JVM that stored it.
If this object declares a floating version of the rules and a background thread is used to update the available rules, then the result of calling this method may vary over time. Each individual call will be still remain thread-safe.
If this is a fixed time-zone, then it is valid if the offset matches the date-time.
- Specified by:
isValidFor
in classTimeZone
- Parameters:
dateTime
- a date-time for which the rules must be valid, null returns false- Returns:
- true if this time-zone is valid and rules are available
-
getRulesValidFor
Description copied from class:TimeZone
Gets the time-zone rules allowing calculations to be performed, ensuring that the date-time and offset specified is valid for the returned rules.The rules provide the functionality associated with a time-zone, such as finding the offset for a given instant or local date-time. Different rules may be returned depending on the group, version and zone.
If this object declares a specific version of the rules, then the result will be of that version providing that the specified date-time is valid for those rules. If this object declares a floating version of the rules, then the latest version of the rules where the date-time is valid will be returned.
A time-zone can be invalid if it is deserialized in a JVM which does not have the same rules loaded as the JVM that stored it. In this case, calling this method will throw an exception.
If this object declares a floating version of the rules and a background thread is used to update the available rules, then the result of calling this method may vary over time. Each individual call will be still remain thread-safe.
- Specified by:
getRulesValidFor
in classTimeZone
- Parameters:
dateTime
- a date-time for which the rules must be valid, not null- Returns:
- the latest rules for this zone where the date-time is valid, never null
-