Class WindowsZone
- All Implemented Interfaces:
Serializable
,Comparable<WindowsZone>
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.
- Since:
- 2.2
- Author:
- Meno Hochschild
- See Also:
- Serialized Form
-
Method Summary
Modifier and TypeMethodDescriptionint
compareTo(WindowsZone other)
The natural order is based on the lexicographical order of the underlying names of windows zones.boolean
Yields all available names of windows zones.int
hashCode()
static WindowsZone
Creates a name reference to a windows zone.Resolves this name reference to a set of various zone ids for given country.resolveSmart(Locale country)
Resolves this name reference to at most one zone id for given country.toString()
Returns the name of this windows zone reference.static String
Deduces the windows name of given timezone reference and region.static String
Deduces the windows name of given timezone reference and region.
-
Method Details
-
getAvailableNames
Yields all available names of windows zones.
- Returns:
- unmodifiable set of zone names for Windows
- Since:
- 2.3
-
of
Creates a name reference to a windows zone.
- Parameters:
name
- standardized windows zone name- Returns:
- new instance of
WindowsZone
- Throws:
IllegalArgumentException
- if given name is not supported- Since:
- 2.2
- See Also:
getAvailableNames()
,toString()
-
equals
-
hashCode
public int hashCode() -
toString
Returns the name of this windows zone reference.
-
toString
Deduces the windows name of given timezone reference and region.
- Parameters:
tzid
- timezone identifier (usually a IANA/Olson-ID like "America/New_York")locale
- regional setting referring to a country- Returns:
- name of windows zone, maybe empty if resolving fails
- Since:
- 3.41/4.36
- See Also:
toString(String, Locale)
-
toString
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.
- Parameters:
tzid
- timezone identifier (usually a IANA/Olson-ID like "America/New_York")locale
- regional setting referring to a country- Returns:
- name of windows zone, maybe empty if resolving fails
- Since:
- 3.41/4.36
- See Also:
Timezone.normalize(String)
-
compareTo
The natural order is based on the lexicographical order of the underlying names of windows zones.
- Specified by:
compareTo
in interfaceComparable<WindowsZone>
- Parameters:
other
- another windows zone name reference- Returns:
- a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object.
-
resolve
Resolves this name reference to a set of various zone ids for given country.
- Parameters:
country
- country reference- Returns:
- set of ids belonging to this windows zone
- Since:
- 2.2
-
resolveSmart
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.- Parameters:
country
- country reference- Returns:
- preferred zone id belonging to this windows zone or not present if given country is not related to this name
- Since:
- 5.0
-