Top Description Inners Fields Constructors Methods
com.ibm.icu.impl

public final Class ZoneMeta

extends Object
Class Inheritance
Imports
java.lang.ref.SoftReference, java.text.ParsePosition, java.util.Collections, .Locale, .MissingResourceException, .Set, .TreeSet, com.ibm.icu.text.NumberFormat, com.ibm.icu.util.Output, .SimpleTimeZone, .TimeZone, .TimeZone.SystemTimeZoneType, .UResourceBundle

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.
Author
Alan Liu
Since
ICU 2.8

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class
ZoneMeta.CustomTimeZoneCache

Custom time zone object cache

private static class
ZoneMeta.SystemTimeZoneCache

System time zone object cache

Field Summary

Modifier and TypeField and Description
private static final boolean
private static ICUCache<String, String>
private static final ZoneMeta.CustomTimeZoneCache
private static final String
private static final String
private static final int
private static final int
private static final int
private static final String
private static final String
private static final String
private static final String
private static SoftReference<Set<String>>
private static SoftReference<Set<String>>
private static SoftReference<Set<String>>
private static ICUCache<String, String>
private static ICUCache<String, Boolean>
private static final ZoneMeta.SystemTimeZoneCache
private static String[]
private static final String

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public static synchronized int

Returns:

the number of zones in the equivalency group containing 'id', or zero if there are no equivalent zones.
countEquivalentIDs
(String
a system time zone ID
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.

private static String
pack-priv static String
formatCustomID(int hour, int min, int sec, boolean negative)

public static Set<String>

Returns:

An immutable set of system IDs for the given conditions.
getAvailableIDs
(TimeZone.SystemTimeZoneType
a system time zone type.
type
,
String
a region, or null.
region
,
Integer
a zone raw offset or null.
rawOffset
)

Returns an immutable set of system IDs for the given conditions.

public static String
public static String
getCanonicalCLDRID(String tzid)

Return the canonical id for this tzid defined by CLDR, which might be the id itself.

public static String
getCanonicalCountry(String tzid)

Return the canonical country code for this tzid.

public static String
getCanonicalCountry(String tzid, Output<Boolean> isPrimary)

Return the canonical country code for this tzid.

private static synchronized Set<String>

Returns:

An immutable set of canonical system time zone IDs that are associated with actual locations.
getCanonicalSystemLocationZIDs
()

Returns an immutable set of canonical system time zone IDs that are associated with actual locations.

private static synchronized Set<String>

Returns:

An immutable set of canonical system time zone IDs.
getCanonicalSystemZIDs
()

Returns an immutable set of canonical system time zone IDs.

public static String

Returns:

The normalized custom id string.
getCustomID
(String
a string of the form GMT[+-]hh:mm, GMT[+-]hhmm, or GMT[+-]hh.
id
)

Parse a custom time zone identifier and return the normalized custom time zone identifier for the given custom id string.

public static SimpleTimeZone

Returns:

a frozen SimpleTimeZone with the given offset and no Daylight Savings Time, or null if the id cannot be parsed.
getCustomTimeZone
(String
a string of the form GMT[+-]hh:mm, GMT[+-]hhmm, or GMT[+-]hh.
id
)

Parse a custom time zone identifier and return a corresponding zone.

public static SimpleTimeZone

Returns:

A custom TimeZone for the offset with normalized time zone id
getCustomTimeZone
(int
GMT offset in milliseconds
offset
)

Creates a custom zone for the offset

public static synchronized String

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
getEquivalentID
(String
a system time zone ID
id
,
int
a value from 0 to n-1, where n is the value returned by countEquivalentIDs(id)
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.

public static String

Returns:

A primary IANA zone ID equivalent to the input zone ID.
getIanaID
(String
An input zone ID.
tzid
)

Returns primary IANA zone ID for the input zone ID. When input zone ID is not known, this method returns null.

public static String
getRegion(String tzid)

Return the region code for this tzid.

public static String

Returns:

the short ID of the time zone, or null if the short ID is not available.
getShortID
(TimeZone
the time zone
tz
)

Returns the time zone's short ID for the zone.

public static String

Returns:

the short ID of the time zone ID, or null if the short ID is not available.
getShortID
(String
the time zone ID
id
)

Returns the time zone's short ID for the zone ID. For example, "uslax" for zone ID "America/Los_Angeles".

private static String
public static OlsonTimeZone
getSystemTimeZone(String id)

Returns a frozen OlsonTimeZone instance for the given ID. This method returns null when the given ID is unknown.

private static synchronized Set<String>

Returns:

An immutable set of system time zone IDs.
getSystemZIDs
()

Returns an immutable set of system time zone IDs.

private static String
getZoneID(int idx)

private static synchronized String[]
private static int
public static UResourceBundle

Returns:

the corresponding zone resource or null if not found
openOlsonResource
(UResourceBundle
the top level resource of the zoneinfo resource or null.
top
,
String
zone id
id
)

Given an ID and the top-level resource of the zoneinfo resource, open the appropriate resource for the given time zone.

pack-priv static boolean
parseCustomID(String id, int[] fields)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

ASSERTback to summary
private static final boolean ASSERT
CANONICAL_ID_CACHEback to summary
private static ICUCache<String, String> CANONICAL_ID_CACHE
CUSTOM_ZONE_CACHEback to summary
private static final ZoneMeta.CustomTimeZoneCache CUSTOM_ZONE_CACHE
kCUSTOM_TZ_PREFIXback to summary
private static final String kCUSTOM_TZ_PREFIX
kGMT_IDback to summary
private static final String kGMT_ID
kMAX_CUSTOM_HOURback to summary
private static final int kMAX_CUSTOM_HOUR
kMAX_CUSTOM_MINback to summary
private static final int kMAX_CUSTOM_MIN
kMAX_CUSTOM_SECback to summary
private static final int kMAX_CUSTOM_SEC
kNAMESback to summary
private static final String kNAMES
kREGIONSback to summary
private static final String kREGIONS
kWorldback to summary
private static final String kWorld
kZONESback to summary
private static final String kZONES
REF_CANONICAL_SYSTEM_LOCATION_ZONESback to summary
private static SoftReference<Set<String>> REF_CANONICAL_SYSTEM_LOCATION_ZONES
REF_CANONICAL_SYSTEM_ZONESback to summary
private static SoftReference<Set<String>> REF_CANONICAL_SYSTEM_ZONES
REF_SYSTEM_ZONESback to summary
private static SoftReference<Set<String>> REF_SYSTEM_ZONES
REGION_CACHEback to summary
private static ICUCache<String, String> REGION_CACHE
SINGLE_COUNTRY_CACHEback to summary
private static ICUCache<String, Boolean> SINGLE_COUNTRY_CACHE
SYSTEM_ZONE_CACHEback to summary
private static final ZoneMeta.SystemTimeZoneCache SYSTEM_ZONE_CACHE
ZONEIDSback to summary
private static String[] ZONEIDS
ZONEINFORESNAMEback to summary
private static final String ZONEINFORESNAME

Constructor Detail

ZoneMetaback to summary
public ZoneMeta()

Method Detail

countEquivalentIDsback to summary
public static synchronized int countEquivalentIDs(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:String

a system time zone ID

Returns:int

the number of zones in the equivalency group containing 'id', or zero if there are no equivalent zones.

See Also
getEquivalentID
findCLDRCanonicalIDback to summary
private static String findCLDRCanonicalID(String tzid)
formatCustomIDback to summary
pack-priv static String formatCustomID(int hour, int min, int sec, boolean negative)
getAvailableIDsback to summary
public static Set<String> getAvailableIDs(TimeZone.SystemTimeZoneType type, String region, Integer rawOffset)

Returns an immutable set of system IDs for the given conditions.

Parameters
type:TimeZone.SystemTimeZoneType

a system time zone type.

region:String

a region, or null.

rawOffset:Integer

a zone raw offset or null.

Returns:Set<String>

An immutable set of system IDs for the given conditions.

getCanonicalCLDRIDback to summary
public static String getCanonicalCLDRID(TimeZone tz)
getCanonicalCLDRIDback to summary
public static String getCanonicalCLDRID(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).

getCanonicalCountryback to summary
public static String getCanonicalCountry(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.

getCanonicalCountryback to summary
public static String getCanonicalCountry(String tzid, Output<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.

getCanonicalSystemLocationZIDsback to summary
private static synchronized Set<String> getCanonicalSystemLocationZIDs()

Returns an immutable set of canonical system time zone IDs that are associated with actual locations. The result set is a subset of getCanonicalSystemZIDs(), but not including IDs, such as "Etc/GTM+5".

Returns:Set<String>

An immutable set of canonical system time zone IDs that are associated with actual locations.

getCanonicalSystemZIDsback to summary
private static synchronized Set<String> getCanonicalSystemZIDs()

Returns an immutable set of canonical system time zone IDs. The result set is a subset of getSystemZIDs(), but not including aliases, such as "US/Eastern".

Returns:Set<String>

An immutable set of canonical system time zone IDs.

getCustomIDback to summary
public static String getCustomID(String id)

Parse a custom time zone identifier and return the normalized custom time zone identifier for the given custom id string.

Parameters
id:String

a string of the form GMT[+-]hh:mm, GMT[+-]hhmm, or GMT[+-]hh.

Returns:String

The normalized custom id string.

getCustomTimeZoneback to summary
public static SimpleTimeZone getCustomTimeZone(String id)

Parse a custom time zone identifier and return a corresponding zone.

Parameters
id:String

a string of the form GMT[+-]hh:mm, GMT[+-]hhmm, or GMT[+-]hh.

Returns:SimpleTimeZone

a frozen SimpleTimeZone with the given offset and no Daylight Savings Time, or null if the id cannot be parsed.

getCustomTimeZoneback to summary
public static SimpleTimeZone getCustomTimeZone(int offset)

Creates a custom zone for the offset

Parameters
offset:int

GMT offset in milliseconds

Returns:SimpleTimeZone

A custom TimeZone for the offset with normalized time zone id

getEquivalentIDback to summary
public static synchronized String getEquivalentID(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:String

a system time zone ID

index:int

a value from 0 to n-1, where n is the value returned by countEquivalentIDs(id)

Returns:String

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
getIanaIDback to summary
public static String getIanaID(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:String

An input zone ID.

Returns:String

A primary IANA zone ID equivalent to the input zone ID.

getRegionback to summary
public static String getRegion(String tzid)

Return the region code for this tzid. If tzid is not a system zone ID, this method returns null.

getShortIDback to summary
public static String getShortID(TimeZone tz)

Returns the time zone's short ID for the zone. For example, "uslax" for zone "America/Los_Angeles".

Parameters
tz:TimeZone

the time zone

Returns:String

the short ID of the time zone, or null if the short ID is not available.

getShortIDback to summary
public static String getShortID(String id)

Returns the time zone's short ID for the zone ID. For example, "uslax" for zone ID "America/Los_Angeles".

Parameters
id:String

the time zone ID

Returns:String

the short ID of the time zone ID, or null if the short ID is not available.

getShortIDFromCanonicalback to summary
private static String getShortIDFromCanonical(String canonicalID)
getSystemTimeZoneback to summary
public static OlsonTimeZone getSystemTimeZone(String id)

Returns a frozen OlsonTimeZone instance for the given ID. This method returns null when the given ID is unknown.

getSystemZIDsback to summary
private static synchronized Set<String> getSystemZIDs()

Returns an immutable set of system time zone IDs. Etc/Unknown is excluded.

Returns:Set<String>

An immutable set of system time zone IDs.

getZoneIDback to summary
private static String getZoneID(int idx)
getZoneIDsback to summary
private static synchronized String[] getZoneIDs()
getZoneIndexback to summary
private static int getZoneIndex(String zid)
openOlsonResourceback to summary
public static UResourceBundle openOlsonResource(UResourceBundle top, 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:UResourceBundle

the top level resource of the zoneinfo resource or null.

id:String

zone id

Returns:UResourceBundle

the corresponding zone resource or null if not found

parseCustomIDback to summary
pack-priv static boolean parseCustomID(String id, int[] fields)
com.ibm.icu.impl back to summary

private Class ZoneMeta.CustomTimeZoneCache

extends SoftCache<Integer, SimpleTimeZone, int[]>
Class Inheritance

Custom time zone object cache

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
protected SimpleTimeZone
createInstance(Integer
Cache lookup key for the requested instance
key
,
int[]
Data for the instance creation
data
)

Implements abstract com.ibm.icu.impl.CacheBase.createInstance.

Creates an instance for the key and data.
Inherited from com.ibm.icu.impl.SoftCache:
getInstance

Constructor Detail

CustomTimeZoneCacheback to summary
private CustomTimeZoneCache()

Method Detail

createInstanceback to summary
protected SimpleTimeZone createInstance(Integer key, int[] data)

Implements abstract com.ibm.icu.impl.CacheBase.createInstance.

Doc from com.ibm.icu.impl.CacheBase.createInstance.

Creates an instance for the key and data. Must be overridden.

Parameters
key:Integer

Cache lookup key for the requested instance

data:int[]

Data for the instance creation

Returns:SimpleTimeZone

The requested instance

Annotations
@Override
com.ibm.icu.impl back to summary

private Class ZoneMeta.SystemTimeZoneCache

extends SoftCache<String, OlsonTimeZone, String>
Class Inheritance

System time zone object cache

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
protected OlsonTimeZone
createInstance(String
Cache lookup key for the requested instance
key
,
String
Data for the instance creation
data
)

Implements abstract com.ibm.icu.impl.CacheBase.createInstance.

Creates an instance for the key and data.
Inherited from com.ibm.icu.impl.SoftCache:
getInstance

Constructor Detail

SystemTimeZoneCacheback to summary
private SystemTimeZoneCache()

Method Detail

createInstanceback to summary
protected OlsonTimeZone createInstance(String key, String data)

Implements abstract com.ibm.icu.impl.CacheBase.createInstance.

Doc from com.ibm.icu.impl.CacheBase.createInstance.

Creates an instance for the key and data. Must be overridden.

Parameters
key:String

Cache lookup key for the requested instance

data:String

Data for the instance creation

Returns:OlsonTimeZone

The requested instance

Annotations
@Override