Class TzdbZoneRulesProvider
- java.lang.Object
-
- java.time.zone.ZoneRulesProvider
-
- java.time.zone.TzdbZoneRulesProvider
-
public class TzdbZoneRulesProvider extends ZoneRulesProvider
Provides zone rules for the time-zones defined by IANA Time Zone Database (TZDB).
-
-
Constructor Summary
Constructors Constructor Description TzdbZoneRulesProvider()Creates a provider and initializes it.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected ZoneRulesprovideRules(java.lang.String zoneId, boolean forCaching)SPI method to get the rules for the zone ID.protected java.util.NavigableMap<java.lang.String,ZoneRules>provideVersions(java.lang.String zoneId)SPI method to get the history of rules for the zone ID.protected java.util.Set<java.lang.String>provideZoneIds()SPI method to get the available zone IDs.-
Methods inherited from class java.time.zone.ZoneRulesProvider
getAvailableZoneIds, getRules, getVersions, provideRefresh, refresh
-
-
-
-
Constructor Detail
-
TzdbZoneRulesProvider
public TzdbZoneRulesProvider() throws java.io.IOExceptionCreates a provider and initializes it.The initialization phase attempts to read from the tzdb binary resource that contains the zone rules. If it fails to open or read the resource, it will throw an exception.
- Throws:
java.io.IOException- if the tzdb binary resource could not be open/read, or the tzdb data is not valid
-
-
Method Detail
-
provideZoneIds
protected java.util.Set<java.lang.String> provideZoneIds()
Description copied from class:ZoneRulesProviderSPI method to get the available zone IDs.This obtains the IDs that this
ZoneRulesProviderprovides. A provider should provide data for at least one zone ID.The returned zone IDs remain available and valid for the lifetime of the application. A dynamic provider may increase the set of IDs as more data becomes available.
- Specified by:
provideZoneIdsin classZoneRulesProvider- Returns:
- the set of zone IDs being provided, not null
-
provideRules
@Nullable protected ZoneRules provideRules(java.lang.String zoneId, boolean forCaching)
Description copied from class:ZoneRulesProviderSPI method to get the rules for the zone ID.This loads the rules for the specified zone ID. The provider implementation must validate that the zone ID is valid and available, throwing a
ZoneRulesExceptionif it is not. The result of the method in the valid case depends on the caching flag.If the provider implementation is not dynamic, then the result of the method must be the non-null set of rules selected by the ID.
If the provider implementation is dynamic, then the flag gives the option of preventing the returned rules from being cached in
ZoneId. When the flag is true, the provider is permitted to return null, where null will prevent the rules from being cached inZoneId. When the flag is false, the provider must return non-null rules.- Specified by:
provideRulesin classZoneRulesProvider- Parameters:
zoneId- the zone ID as defined byZoneId, not nullforCaching- whether the rules are being queried for caching, true if the returned rules will be cached byZoneId, false if they will be returned to the user without being cached inZoneId- Returns:
- the rules, null if
forCachingis true and this is a dynamic provider that wants to prevent caching inZoneId, otherwise not null
-
provideVersions
protected java.util.NavigableMap<java.lang.String,ZoneRules> provideVersions(java.lang.String zoneId)
Description copied from class:ZoneRulesProviderSPI method to get the history of rules for the zone ID.This returns a map of historical rules keyed by a version string. The exact meaning and format of the version is provider specific. The version must follow lexicographical order, thus the returned map will be ordered from the oldest known rules to the newest available rules.
Implementations must provide a result for each valid zone ID, however they do not have to provide a history of rules. Thus, the map will contain at least one element, and will only contain more than one element if historical rule information is available.
The returned versions remain available and valid for the lifetime of the application. A dynamic provider may increase the set of versions as more data becomes available.
- Specified by:
provideVersionsin classZoneRulesProvider- Parameters:
zoneId- the zone ID as defined byZoneId, not null- Returns:
- a modifiable copy of the history of the rules for the ID, sorted from oldest to newest, not null
-
-