Class TzdbZoneRulesProvider
- java.lang.Object
-
- org.threeten.bp.zone.ZoneRulesProvider
-
- org.threeten.bp.zone.TzdbZoneRulesProvider
-
public final class TzdbZoneRulesProvider extends ZoneRulesProvider
Loads time-zone rules for 'TZDB'.This class is public for the service loader to access.
Specification for implementors
This class is immutable and thread-safe.
-
-
Constructor Summary
Constructors Constructor Description TzdbZoneRulesProvider()
Creates an instance.TzdbZoneRulesProvider(InputStream stream)
Creates an instance and loads the specified input stream.TzdbZoneRulesProvider(URL url)
Creates an instance and loads the specified URL.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected ZoneRules
provideRules(String zoneId, boolean forCaching)
SPI method to get the rules for the zone ID.protected NavigableMap<String,ZoneRules>
provideVersions(String zoneId)
SPI method to get the history of rules for the zone ID.protected Set<String>
provideZoneIds()
SPI method to get the available zone IDs.String
toString()
-
Methods inherited from class org.threeten.bp.zone.ZoneRulesProvider
getAvailableZoneIds, getRules, getVersions, provideRefresh, refresh, registerProvider
-
-
-
-
Constructor Detail
-
TzdbZoneRulesProvider
public TzdbZoneRulesProvider()
Creates an instance. Created by theServiceLoader
.- Throws:
ZoneRulesException
- if unable to load
-
TzdbZoneRulesProvider
public TzdbZoneRulesProvider(URL url)
Creates an instance and loads the specified URL.This could be used to wrap this provider in another instance.
- Parameters:
url
- the URL to load, not null- Throws:
ZoneRulesException
- if unable to load
-
TzdbZoneRulesProvider
public TzdbZoneRulesProvider(InputStream stream)
Creates an instance and loads the specified input stream.This could be used to wrap this provider in another instance.
- Parameters:
stream
- the stream to load, not null, not closed after use- Throws:
ZoneRulesException
- if unable to load
-
-
Method Detail
-
provideZoneIds
protected Set<String> provideZoneIds()
Description copied from class:ZoneRulesProvider
SPI method to get the available zone IDs.This obtains the IDs that this
ZoneRulesProvider
provides. A provider should provide data for at least one region.The returned regions remain available and valid for the lifetime of the application. A dynamic provider may increase the set of regions as more data becomes available.
- Specified by:
provideZoneIds
in classZoneRulesProvider
- Returns:
- the unmodifiable set of region IDs being provided, not null
-
provideRules
protected ZoneRules provideRules(String zoneId, boolean forCaching)
Description copied from class:ZoneRulesProvider
SPI method to get the rules for the zone ID.This loads the rules for the region and version specified. The version may be null to indicate the "latest" version.
- Specified by:
provideRules
in classZoneRulesProvider
- Parameters:
zoneId
- the time-zone region ID, not null- Returns:
- the rules, not null
-
provideVersions
protected NavigableMap<String,ZoneRules> provideVersions(String zoneId)
Description copied from class:ZoneRulesProvider
SPI 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 order from the oldest known rules to the newest available rules. The default 'TZDB' group uses version numbering consisting of the year followed by a letter, such as '2009e' or '2012f'.
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 always contain 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:
provideVersions
in classZoneRulesProvider
- Parameters:
zoneId
- the zone region ID as used byZoneId
, not null- Returns:
- a modifiable copy of the history of the rules for the ID, sorted from oldest to newest, not null
-
-