public final class WindowsZone extends Object implements Comparable<WindowsZone>, Serializable
Represents a windows timezone name which can be mapped to an IANA/Olson-ID using a territory information.
Example:
WindowsZone wzn = WindowsZone.of("Eastern Standard Time");
TZID winzone = wzn.resolveSmart(Locale.US);
System.out.println(winzone.canonical());
// output: WINDOWS~America/New_York
The reverse way:
String winzone = WindowsZone.toString("America/New_York", Locale.US);
System.out.println(winzone);
// output: Eastern Standard Time
Note: A perfect roundtrip is often not possible because there are many more IANA-zone identifiers than windows zones. For best results, it is recommended to use the tzdata-module and not the standard timezone data of the underlying platform.
| Modifier and Type | Method and Description |
|---|---|
int |
compareTo(WindowsZone other)
The natural order is based on the lexicographical order of the
underlying names of windows zones.
|
boolean |
equals(Object obj) |
static Set<String> |
getAvailableNames()
Yields all available names of windows zones.
|
int |
hashCode() |
static WindowsZone |
of(String name)
Creates a name reference to a windows zone.
|
Set<TZID> |
resolve(Locale country)
Resolves this name reference to a set of various zone ids for given
country.
|
Optional<TZID> |
resolveSmart(Locale country)
Resolves this name reference to at most one zone id for given
country.
|
String |
toString()
Returns the name of this windows zone reference.
|
static String |
toString(String tzid,
Locale locale)
Deduces the windows name of given timezone reference and region.
|
static String |
toString(TZID tzid,
Locale locale)
Deduces the windows name of given timezone reference and region.
|
public static Set<String> getAvailableNames()
Yields all available names of windows zones.
public static WindowsZone of(String name)
Creates a name reference to a windows zone.
name - standardized windows zone nameWindowsZoneIllegalArgumentException - if given name is not supportedgetAvailableNames(),
toString()public String toString()
Returns the name of this windows zone reference.
public static String toString(TZID tzid, Locale locale)
Deduces the windows name of given timezone reference and region.
tzid - timezone identifier (usually a IANA/Olson-ID like "America/New_York")locale - regional setting referring to a countrytoString(String, Locale)public static String toString(String tzid, Locale locale)
Deduces the windows name of given timezone reference and region.
This method first tries all to automatically normalize given timezone identifier before resolving to the windows name. Normalizing works best if the tzdata-module is present.
tzid - timezone identifier (usually a IANA/Olson-ID like "America/New_York")locale - regional setting referring to a countryTimezone.normalize(String)public int compareTo(WindowsZone other)
The natural order is based on the lexicographical order of the underlying names of windows zones.
compareTo in interface Comparable<WindowsZone>other - another windows zone name referencepublic Set<TZID> resolve(Locale country)
Resolves this name reference to a set of various zone ids for given country.
country - country referencepublic Optional<TZID> resolveSmart(Locale country)
Resolves this name reference to at most one zone id for given country.
Normally windows zones cannot be resolved to one single zone id, but there is usually one preferred zone id based on the fact that the daylight saving rules for this name and given country are often the same for all belonging zone ids in the recent past. This method tries its best to yield a result but applications have to check if a result is available.
Important: The country reference must be given, that is,
country.getCountry() must not be empty otherwise this method
will not return any result.
country - country referenceCopyright © 2014–2021. All rights reserved.