Package com.ibm.icu.impl
Class ZoneMeta
- java.lang.Object
-
- com.ibm.icu.impl.ZoneMeta
-
public final class ZoneMeta extends java.lang.Object
This class, not to be instantiated, implements the meta-data missing from the underlying core JDK implementation of time zones. There are two missing features: Obtaining a list of available zones for a given country (as defined by the Olson database), and obtaining a list of equivalent zones for a given zone (as defined by Olson links). This class uses a data class, ZoneMetaData, which is created by the tool tz2icu.- Since:
- ICU 2.8
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static class
ZoneMeta.CustomTimeZoneCache
Custom time zone object cacheprivate static class
ZoneMeta.SystemTimeZoneCache
System time zone object cache
-
Field Summary
Fields Modifier and Type Field Description private static boolean
ASSERT
private static ICUCache<java.lang.String,java.lang.String>
CANONICAL_ID_CACHE
private static ZoneMeta.CustomTimeZoneCache
CUSTOM_ZONE_CACHE
private static java.lang.String
kCUSTOM_TZ_PREFIX
private static java.lang.String
kGMT_ID
private static int
kMAX_CUSTOM_HOUR
private static int
kMAX_CUSTOM_MIN
private static int
kMAX_CUSTOM_SEC
private static java.lang.String
kNAMES
private static java.lang.String
kREGIONS
private static java.lang.String
kWorld
private static java.lang.String
kZONES
private static java.lang.ref.SoftReference<java.util.Set<java.lang.String>>
REF_CANONICAL_SYSTEM_LOCATION_ZONES
private static java.lang.ref.SoftReference<java.util.Set<java.lang.String>>
REF_CANONICAL_SYSTEM_ZONES
private static java.lang.ref.SoftReference<java.util.Set<java.lang.String>>
REF_SYSTEM_ZONES
private static ICUCache<java.lang.String,java.lang.String>
REGION_CACHE
private static ICUCache<java.lang.String,java.lang.Boolean>
SINGLE_COUNTRY_CACHE
private static ZoneMeta.SystemTimeZoneCache
SYSTEM_ZONE_CACHE
private static java.lang.String[]
ZONEIDS
private static java.lang.String
ZONEINFORESNAME
-
Constructor Summary
Constructors Constructor Description ZoneMeta()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static int
countEquivalentIDs(java.lang.String id)
Returns the number of IDs in the equivalency group that includes the given ID.private static java.lang.String
findCLDRCanonicalID(java.lang.String tzid)
(package private) static java.lang.String
formatCustomID(int hour, int min, int sec, boolean negative)
static java.util.Set<java.lang.String>
getAvailableIDs(TimeZone.SystemTimeZoneType type, java.lang.String region, java.lang.Integer rawOffset)
Returns an immutable set of system IDs for the given conditions.static java.lang.String
getCanonicalCLDRID(TimeZone tz)
static java.lang.String
getCanonicalCLDRID(java.lang.String tzid)
Return the canonical id for this tzid defined by CLDR, which might be the id itself.static java.lang.String
getCanonicalCountry(java.lang.String tzid)
Return the canonical country code for this tzid.static java.lang.String
getCanonicalCountry(java.lang.String tzid, Output<java.lang.Boolean> isPrimary)
Return the canonical country code for this tzid.private static java.util.Set<java.lang.String>
getCanonicalSystemLocationZIDs()
Returns an immutable set of canonical system time zone IDs that are associated with actual locations.private static java.util.Set<java.lang.String>
getCanonicalSystemZIDs()
Returns an immutable set of canonical system time zone IDs.static java.lang.String
getCustomID(java.lang.String id)
Parse a custom time zone identifier and return the normalized custom time zone identifier for the given custom id string.static SimpleTimeZone
getCustomTimeZone(int offset)
Creates a custom zone for the offsetstatic SimpleTimeZone
getCustomTimeZone(java.lang.String id)
Parse a custom time zone identifier and return a corresponding zone.static java.lang.String
getEquivalentID(java.lang.String id, int index)
Returns an ID in the equivalency group that includes the given ID.static java.lang.String
getIanaID(java.lang.String tzid)
Returns primary IANA zone ID for the input zone ID.static java.lang.String
getRegion(java.lang.String tzid)
Return the region code for this tzid.static java.lang.String
getShortID(TimeZone tz)
Returns the time zone's short ID for the zone.static java.lang.String
getShortID(java.lang.String id)
Returns the time zone's short ID for the zone ID.private static java.lang.String
getShortIDFromCanonical(java.lang.String canonicalID)
static OlsonTimeZone
getSystemTimeZone(java.lang.String id)
Returns a frozen OlsonTimeZone instance for the given ID.private static java.util.Set<java.lang.String>
getSystemZIDs()
Returns an immutable set of system time zone IDs.private static java.lang.String
getZoneID(int idx)
private static java.lang.String[]
getZoneIDs()
private static int
getZoneIndex(java.lang.String zid)
static UResourceBundle
openOlsonResource(UResourceBundle top, java.lang.String id)
Given an ID and the top-level resource of the zoneinfo resource, open the appropriate resource for the given time zone.(package private) static boolean
parseCustomID(java.lang.String id, int[] fields)
-
-
-
Field Detail
-
ASSERT
private static final boolean ASSERT
- See Also:
- Constant Field Values
-
ZONEINFORESNAME
private static final java.lang.String ZONEINFORESNAME
- See Also:
- Constant Field Values
-
kREGIONS
private static final java.lang.String kREGIONS
- See Also:
- Constant Field Values
-
kZONES
private static final java.lang.String kZONES
- See Also:
- Constant Field Values
-
kNAMES
private static final java.lang.String kNAMES
- See Also:
- Constant Field Values
-
kGMT_ID
private static final java.lang.String kGMT_ID
- See Also:
- Constant Field Values
-
kCUSTOM_TZ_PREFIX
private static final java.lang.String kCUSTOM_TZ_PREFIX
- See Also:
- Constant Field Values
-
kWorld
private static final java.lang.String kWorld
- See Also:
- Constant Field Values
-
REF_SYSTEM_ZONES
private static java.lang.ref.SoftReference<java.util.Set<java.lang.String>> REF_SYSTEM_ZONES
-
REF_CANONICAL_SYSTEM_ZONES
private static java.lang.ref.SoftReference<java.util.Set<java.lang.String>> REF_CANONICAL_SYSTEM_ZONES
-
REF_CANONICAL_SYSTEM_LOCATION_ZONES
private static java.lang.ref.SoftReference<java.util.Set<java.lang.String>> REF_CANONICAL_SYSTEM_LOCATION_ZONES
-
ZONEIDS
private static java.lang.String[] ZONEIDS
-
CANONICAL_ID_CACHE
private static ICUCache<java.lang.String,java.lang.String> CANONICAL_ID_CACHE
-
REGION_CACHE
private static ICUCache<java.lang.String,java.lang.String> REGION_CACHE
-
SINGLE_COUNTRY_CACHE
private static ICUCache<java.lang.String,java.lang.Boolean> SINGLE_COUNTRY_CACHE
-
SYSTEM_ZONE_CACHE
private static final ZoneMeta.SystemTimeZoneCache SYSTEM_ZONE_CACHE
-
kMAX_CUSTOM_HOUR
private static final int kMAX_CUSTOM_HOUR
- See Also:
- Constant Field Values
-
kMAX_CUSTOM_MIN
private static final int kMAX_CUSTOM_MIN
- See Also:
- Constant Field Values
-
kMAX_CUSTOM_SEC
private static final int kMAX_CUSTOM_SEC
- See Also:
- Constant Field Values
-
CUSTOM_ZONE_CACHE
private static final ZoneMeta.CustomTimeZoneCache CUSTOM_ZONE_CACHE
-
-
Method Detail
-
getSystemZIDs
private static java.util.Set<java.lang.String> getSystemZIDs()
Returns an immutable set of system time zone IDs. Etc/Unknown is excluded.- Returns:
- An immutable set of system time zone IDs.
-
getCanonicalSystemZIDs
private static java.util.Set<java.lang.String> getCanonicalSystemZIDs()
Returns an immutable set of canonical system time zone IDs. The result set is a subset ofgetSystemZIDs()
, but not including aliases, such as "US/Eastern".- Returns:
- An immutable set of canonical system time zone IDs.
-
getCanonicalSystemLocationZIDs
private static java.util.Set<java.lang.String> getCanonicalSystemLocationZIDs()
Returns an immutable set of canonical system time zone IDs that are associated with actual locations. The result set is a subset ofgetCanonicalSystemZIDs()
, but not including IDs, such as "Etc/GTM+5".- Returns:
- An immutable set of canonical system time zone IDs that are associated with actual locations.
-
getAvailableIDs
public static java.util.Set<java.lang.String> getAvailableIDs(TimeZone.SystemTimeZoneType type, java.lang.String region, java.lang.Integer rawOffset)
Returns an immutable set of system IDs for the given conditions.- Parameters:
type
- a system time zone type.region
- a region, or null.rawOffset
- a zone raw offset or null.- Returns:
- An immutable set of system IDs for the given conditions.
-
countEquivalentIDs
public static int countEquivalentIDs(java.lang.String id)
Returns the number of IDs in the equivalency group that includes the given ID. An equivalency group contains zones that behave identically to the given zone.If there are no equivalent zones, then this method returns 0. This means either the given ID is not a valid zone, or it is and there are no other equivalent zones.
- Parameters:
id
- a system time zone ID- Returns:
- the number of zones in the equivalency group containing 'id', or zero if there are no equivalent zones.
- See Also:
getEquivalentID(java.lang.String, int)
-
getEquivalentID
public static java.lang.String getEquivalentID(java.lang.String id, int index)
Returns an ID in the equivalency group that includes the given ID. An equivalency group contains zones that behave identically to the given zone.The given index must be in the range 0..n-1, where n is the value returned by
countEquivalentIDs(id)
. For some value of 'index', the returned value will be equal to the given id. If the given id is not a valid system time zone, or if 'index' is out of range, then returns an empty string.- Parameters:
id
- a system time zone IDindex
- a value from 0 to n-1, where n is the value returned bycountEquivalentIDs(id)
- Returns:
- the ID of the index-th zone in the equivalency group containing 'id', or an empty string if 'id' is not a valid system ID or 'index' is out of range
- See Also:
countEquivalentIDs(java.lang.String)
-
getZoneIDs
private static java.lang.String[] getZoneIDs()
-
getZoneID
private static java.lang.String getZoneID(int idx)
-
getZoneIndex
private static int getZoneIndex(java.lang.String zid)
-
getCanonicalCLDRID
public static java.lang.String getCanonicalCLDRID(TimeZone tz)
-
getCanonicalCLDRID
public static java.lang.String getCanonicalCLDRID(java.lang.String tzid)
Return the canonical id for this tzid defined by CLDR, which might be the id itself. If the given tzid is not known, return null. Note: This internal API supports all known system IDs and "Etc/Unknown" (which is NOT a system ID).
-
findCLDRCanonicalID
private static java.lang.String findCLDRCanonicalID(java.lang.String tzid)
-
getIanaID
public static java.lang.String getIanaID(java.lang.String tzid)
Returns primary IANA zone ID for the input zone ID. When input zone ID is not known, this method returns null.- Parameters:
tzid
- An input zone ID.- Returns:
- A primary IANA zone ID equivalent to the input zone ID.
-
getRegion
public static java.lang.String getRegion(java.lang.String tzid)
Return the region code for this tzid. If tzid is not a system zone ID, this method returns null.
-
getCanonicalCountry
public static java.lang.String getCanonicalCountry(java.lang.String tzid)
Return the canonical country code for this tzid. If we have none, or if the time zone is not associated with a country or unknown, return null.
-
getCanonicalCountry
public static java.lang.String getCanonicalCountry(java.lang.String tzid, Output<java.lang.Boolean> isPrimary)
Return the canonical country code for this tzid. If we have none, or if the time zone is not associated with a country or unknown, return null. When the given zone is the primary zone of the country, true is set to isPrimary.
-
openOlsonResource
public static UResourceBundle openOlsonResource(UResourceBundle top, java.lang.String id)
Given an ID and the top-level resource of the zoneinfo resource, open the appropriate resource for the given time zone. Dereference links if necessary.- Parameters:
top
- the top level resource of the zoneinfo resource or null.id
- zone id- Returns:
- the corresponding zone resource or null if not found
-
getSystemTimeZone
public static OlsonTimeZone getSystemTimeZone(java.lang.String id)
Returns a frozen OlsonTimeZone instance for the given ID. This method returns null when the given ID is unknown.
-
getCustomTimeZone
public static SimpleTimeZone getCustomTimeZone(java.lang.String id)
Parse a custom time zone identifier and return a corresponding zone.- Parameters:
id
- a string of the form GMT[+-]hh:mm, GMT[+-]hhmm, or GMT[+-]hh.- Returns:
- a frozen SimpleTimeZone with the given offset and no Daylight Savings Time, or null if the id cannot be parsed.
-
getCustomID
public static java.lang.String getCustomID(java.lang.String id)
Parse a custom time zone identifier and return the normalized custom time zone identifier for the given custom id string.- Parameters:
id
- a string of the form GMT[+-]hh:mm, GMT[+-]hhmm, or GMT[+-]hh.- Returns:
- The normalized custom id string.
-
parseCustomID
static boolean parseCustomID(java.lang.String id, int[] fields)
-
getCustomTimeZone
public static SimpleTimeZone getCustomTimeZone(int offset)
Creates a custom zone for the offset- Parameters:
offset
- GMT offset in milliseconds- Returns:
- A custom TimeZone for the offset with normalized time zone id
-
formatCustomID
static java.lang.String formatCustomID(int hour, int min, int sec, boolean negative)
-
getShortID
public static java.lang.String getShortID(TimeZone tz)
Returns the time zone's short ID for the zone. For example, "uslax" for zone "America/Los_Angeles".- Parameters:
tz
- the time zone- Returns:
- the short ID of the time zone, or null if the short ID is not available.
-
getShortID
public static java.lang.String getShortID(java.lang.String id)
Returns the time zone's short ID for the zone ID. For example, "uslax" for zone ID "America/Los_Angeles".- Parameters:
id
- the time zone ID- Returns:
- the short ID of the time zone ID, or null if the short ID is not available.
-
getShortIDFromCanonical
private static java.lang.String getShortIDFromCanonical(java.lang.String canonicalID)
-
-