TimeZoneFormat supports time zone display name formatting and parsing.
An instance of TimeZoneFormat works as a subformatter of SimpleDateFormat,
but you can also directly get a new instance of TimeZoneFormat and
formatting/parsing time zone display names.
ICU implements the time zone display names defined by UTS#35
Unicode Locale Data Markup Language (LDML). TimeZoneNames represents the
time zone display name data model and this class implements the algorithm for actual
formatting and parsing.
SimpleDateFormat, TimeZoneNames
| Modifier and Type | Class and Description |
|---|---|
| private static class | TimeZoneFormat.GMTOffsetField
Used for representing localized GMT time fields in the parsed pattern object. |
| public static enum | TimeZoneFormat.GMTOffsetPatternType
Offset pattern type enum. |
| private static enum | TimeZoneFormat.OffsetFields
Numeric offset field combinations |
| public static enum | TimeZoneFormat.ParseOption
Parse option enum, used for specifying optional parse behavior. |
| public static enum | TimeZoneFormat.Style
Time zone display format style enum used by format/parse APIs in |
| public static enum | TimeZoneFormat.TimeType
Time type enum used for receiving time type (standard time, daylight time or unknown)
in |
| private static class | TimeZoneFormat.TimeZoneFormatCache
Implements |
| Modifier and Type | Field and Description |
|---|---|
| private transient boolean | |
| private transient volatile boolean | |
| private String[] | |
| private transient Object[][] | |
| private String[] | |
| private String | |
| private transient String | |
| private transient String | |
| private String | |
| private transient volatile TimeZoneGenericNames | |
| private ULocale | |
| private boolean | |
| private boolean | |
| private transient String | |
| private transient volatile TimeZoneNames | |
| private static TimeZoneFormat. | |
| private TimeZoneNames | |
| private static final EnumSet | |
| private static final EnumSet | |
| private static final String[] | |
| private static final String | |
| private static final String[] | |
| private static final char | |
| private static final String | |
| private static final String | |
| private static final String | |
| private static final int | |
| private static final int | |
| private static final int | |
| private static final int | |
| private static final int | |
| private static final int | |
| private static final int | |
| private static final int | |
| private static final int | |
| private static final TimeZoneFormat. | |
| private static final ObjectStreamField[] | |
| private static final long | |
| private static volatile TextTrieMap | |
| private static final String | |
| private static final String | |
| private static final int | |
| private static final String | |
| private static final String | |
| private static volatile TextTrieMap |
| Access | Constructor and Description |
|---|---|
| protected |
| Modifier and Type | Method and Description |
|---|---|
| private void | appendOffsetDigits(StringBuilder
the target buffer buf, int the integer number n, int the minimum digits width minDigits)Appends localized digits to the buffer. |
| private void | |
| public TimeZoneFormat | cloneAsThawed()
Implements com. |
| private static String | Returns: the offset pattern including hours, minutes and seconds fieldsthe offset pattern including hours and minutes fields offsetHM)Appends seconds field to the offset pattern with hour/minute |
| public final String | Returns: the display name of the time zone.the style enum (e.g. style,GENERIC_LONG, LOCALIZED_GMT...)the time zone. tz, long the date. date)Returns the display name of the time zone at the given date for the style. |
| public String | Returns: the display name of the time zone.the style enum (e.g. style,GENERIC_LONG, LOCALIZED_GMT...)the time zone. tz, long the date. date, Output<TimeZoneFormat.the output argument for receiving the time type (standard/daylight/unknown)
used for the display name, or specify null if the information is not necessary. timeTypeReturns the display name of the time zone at the given date for the style. |
| public StringBuffer | format(Object
The object to format obj, StringBuffer where the text is to be appended toAppendTo, FieldPosition A pos)FieldPosition identifying a field
in the formatted textImplements abstract java. |
| private String | Returns: the time zone's exemplar location name.the time zone tz)Private method returning the time zone's exemplar location string. |
| private String | formatOffsetISO8601(int offset, boolean isBasic, boolean useUtcIndicator, boolean isShort, boolean ignoreSeconds)
|
| public final String | Returns: the ISO 8601 basic format.the offset from GMT(UTC) in milliseconds. offset, boolean true if ISO 8601 UTC indicator "Z" is used when the offset is 0. useUtcIndicator, boolean true if shortest form is used. isShort, boolean true if non-zero offset seconds is appended. ignoreSeconds)Returns the ISO 8601 basic time zone string for the given offset. |
| public final String | Returns: the ISO 8601 extended format.the offset from GMT(UTC) in milliseconds. offset, boolean true if ISO 8601 UTC indicator "Z" is used when the offset is 0. useUtcIndicator, boolean true if shortest form is used. isShort, boolean true if non-zero offset seconds is appended. ignoreSeconds)Returns the ISO 8601 extended time zone string for the given offset. |
| public String | Returns: the localized GMT format stringthe offset from GMT(UTC) in milliseconds. offset)Returns the localized GMT(UTC) offset format for the given offset. |
| private String | Returns: the localized GMT stringthe zone's UTC offset offset, boolean true if the short localized GMT format is desired isShort)Private method used for localized GMT formatting. |
| public String | Returns: the short localized GMT format stringthe offset from GMT(UTC) in milliseconds. offset)Returns the short localized GMT(UTC) offset format for the given offset. |
| private String | Returns: the time zone's specific format name stringthe time zone tz, TimeZoneNames.the name type used for standard time stdType,the name type used for daylight time dstType,the date date, Output<TimeZoneFormat.when null, actual time type is set timeTypePrivate method returning the time zone's specific format string. |
| public AttributedCharacterIterator | formatToCharacterIterator(Object
The object to format obj)Overrides java. AttributedCharacterIterator.
|
| public TimeZoneFormat | |
| public EnumSet | Returns: the default parse options.Returns the default parse options used by this |
| public String | Returns: the decimal digits for localized GMT format.Returns the decimal digit characters used for localized GMT format in a single string containing from 0 to 9 in the ascending order. |
| public String | getGMTOffsetPattern(TimeZoneFormat.
the offset pattern enum typeReturns the offset pattern used for localized GMT format. |
| public String | |
| public String | Returns: the localized GMT string string for GMT(UTC) itself.Returns the localized GMT format string for GMT(UTC) itself (GMT offset is 0). |
| public static TimeZoneFormat | Returns: a frozen instance ofTimeZoneFormat for the given locale.the locale. locale)Returns a frozen instance of |
| public static TimeZoneFormat | Returns: a frozen instance ofTimeZoneFormat for the given locale.the locale)Locale.Returns a frozen instance of |
| private synchronized String | |
| private TimeZoneFormat. | Returns: the time type (unknown/standard/daylight)the name type nameTypeReturns the time type for the given name type |
| private TimeZone | Returns: A TimeZone with the given offsetthe offset offset)Creates an instance of TimeZone for the given offset |
| private TimeZoneGenericNames | Returns: the instance of TimeZoneGenericNames used by this object.Private method returning the instance of TimeZoneGenericNames used by this object. |
| private String | Returns: A time zone IDthe time zone ID or null tzID, String the meta zone ID or null mzID)Private method returns a time zone ID. If tzID is not null, the value of tzID is returned. |
| public TimeZoneNames | Returns: the time zone display name data.Returns the time zone display name data used by this instance. |
| private TimeZoneNames | Returns: an instance of TZDBTimeZoneNames.Private method returning the instance of TZDBTimeZoneNames. |
| private void | initGMTOffsetPatterns(String[]
patterns, String[4] gmtOffsetPatterns)Initialize localized GMT format offset hour/min/sec patterns. |
| private void | initGMTPattern(String
the localized GMT pattern string such as "GMT {0}" gmtPattern)Parses the localized GMT pattern string and initialize
localized gmt pattern fields including |
| public boolean | isFrozen()
Implements com. |
| public TimeZone | Returns: ATimeZone, or null if the input could not be parsed.the format style. style,the text contains a time zone string at the position. text, ParsePosition the position. pos, EnumSet<TimeZoneFormat.the parse options. options,The output argument for receiving the time type (standard/daylight/unknown),
or specify null if the information is not necessary. timeTypeReturns a |
| public TimeZone | Returns: ATimeZone, or null if the input could not be parsed.the format style style,the text contains a time zone string at the position. text, ParsePosition the position. pos, Output<TimeZoneFormat.The output argument for receiving the time type (standard/daylight/unknown),
or specify null if the information is not necessary. timeTypeReturns a |
| public final TimeZone | Returns: ATimeZone, or null if the input could not be parsed.the text contains a time zone string at the position. text, ParsePosition the position. pos)Returns a |
| public final TimeZone | |
| private static int | Returns: Parsed offset, 0 or positive number.The text contains a sequence of ASCII digits text, ParsePosition The parse position pos, TimeZoneFormat.The minimum Fields to be parsed minFields,The maximum Fields to be parsed maxFields,true if hours field must be width of 2 fixedHourWidth)Parses offset represented by contiguous ASCII digits Note This method expects the input position is already at the start of ASCII digits and does not parse sign (+/-). |
| private int | Returns: the parsed offset in milliseconds.the input text text, int the start index start, int[] the parsed length, or 0 on failure parsedLen)Parses abutting localized GMT offset fields (such as 0800) into offset. |
| private static int | Returns: Parsed offset, 0 or positive number.The text text, ParsePosition The parse position pos, char The separator character sep, TimeZoneFormat.The minimum Fields to be parsed minFields,The maximum Fields to be parsed maxFieldsParses offset represented by ASCII digits and separators. |
| private int | Returns: the parsed offset in milliseconds.the input text text, int the start index start, char the separator character, e.g. separator, int[] the parsed length, or 0 on failure. parsedLen)Parses the input GMT offset fields with the default offset pattern. |
| private String | Returns: The zone ID for the parsed exemplar location.the text contains an exemplar location string at the position. text, ParsePosition the position. pos)Parse an exemplar location string. |
| public Object | parseObject(String
A source, ParsePosition String, part of which should be parsed.A pos)ParsePosition object with index and error
index information as described above.Implements abstract java. |
| private int | Returns: the parsed offset in milliseconds.the input text text, int the start index start, int[] the parsed length, or 0 on failure parsedLen)Parses the input text using the default format patterns (e.g. "UTC{0}"). |
| private int | Returns: the parsed offset in milliseconds.the input text text, int the start index start, boolean true if this is a short format - currently not used isShort, int[] the parsed length, or 0 on failure. parsedLen)Parses localized GMT offset fields into offset. |
| private int | Returns: parsed lengththe input text text, int the start index start, Object[] the pattern (already itemized) patternItems, boolean true if hours field is parsed as a single digit forceSingleHourDigit, int[] receives the parsed hours/minutes/seconds fields)Parses localized GMT offset fields with the given pattern |
| private int | Returns: the integer value parsedthe text text, int the start offset start, int the minimum number of required digits minDigits, int the maximum number of digits maxDigits, int the minimum value minVal, int the maximum value maxVal, int[] the actual parsed length is set to parsedLen[0], must not be null. parsedLen)Reads an offset field value. |
| public final int | Returns: the offset from GMT(UTC) in milliseconds for the given ISO 8601 style time zone string.the text contains ISO 8601 style time zone string (e.g. "-08", "-0800", "-08:00", and "Z")
at the position. text, ParsePosition the position. pos)Returns offset from GMT(UTC) in milliseconds for the given ISO 8601 basic or extended time zone string. |
| private static int | Returns: the offset from GMT(UTC) in milliseconds for the given ISO 8601 style time zone string.the text contains ISO 8601 style time zone string (e.g. "-08", "-08:00", "Z")
at the position. text, ParsePosition the position. pos, boolean true if parsing the text as ISO 8601 extended offset format (e.g. "-08:00"),
or false to evaluate the text as basic format.receiving if the parsed zone string contains offset digits. hasDigitOffset)Returns offset from GMT(UTC) in milliseconds for the given ISO 8601 time zone string (basic format, extended format, or UTC indicator). |
| public int | Returns: the offset from GMT(UTC) in milliseconds for the given localized GMT offset format string.the text contains a localized GMT offset string at the position. text, ParsePosition the position. pos)Returns offset from GMT(UTC) in milliseconds for the given localized GMT offset format string. |
| private int | Returns: the offset from GMT(UTC) in milliseconds for the given localized GMT offset format string.the text contains a localized GMT offset string at the position. text, ParsePosition the position. pos, boolean true if this parser to try the short format first isShort, Output<Boolean> receiving if the parsed zone string contains offset digits. hasDigitOffset)Returns offset from GMT(UTC) in milliseconds for the given localized GMT offset format string. |
| private int | Returns: the parsed offset in milliseconds.the input text text, int the start index start, boolean true if the short localized GMT format is parsed. isShort, int[] the parsed length, or 0 on failure. parsedLen)Parse localized GMT format generated by the pattern used by this formatter, except GMT Zero format. |
| private static Object[] | Returns: An array of Object. Each array entry is either String (representing pattern literal) or GMTOffsetField (hour/min/sec field)the offset pattern string pattern, String the required pattern letters such as "Hm" letters)Parse the GMT offset pattern into runtime optimized format |
| public int | Returns: the offset from GMT(UTC) in milliseconds for the given short localized GMT offset format string.the text contains a short localized GMT offset string at the position. text, ParsePosition the position. pos)Returns offset from GMT(UTC) in milliseconds for the given short localized GMT offset format string. |
| private static String | Returns: The zone ID for the parsed short zone ID.the text contains a time zone ID string at the position. text, ParsePosition the position. pos)Parse a short zone ID. |
| private int | Returns: the integer value of the parsed digit, or -1 on failure.the text text, int the start index start, int[] the actual length read from the text
the start index is not a decimal number. len)Reads a single decimal digit, either localized digits used by this object or any Unicode numeric character. |
| private static String | Returns: The zone ID parsed.the text contains a time zone ID string at the position. text, ParsePosition the position. pos)Parse a zone ID. |
| private void | |
| public TimeZoneFormat | Returns: this object.the default parse options. optionsSets the default parse options. |
| public TimeZoneFormat | Returns: this object.a string contains the decimal digit characters from 0 to 9 n the ascending order. digits)Sets the decimal digit characters used for localized GMT format. |
| public TimeZoneFormat | Returns: this object.the offset pattern. type,the pattern string. pattern)Sets the offset pattern for the given offset type. |
| public TimeZoneFormat | Returns: this object.the localized GMT format pattern string pattern)Sets the localized GMT format pattern. |
| public TimeZoneFormat | Returns: this object.the localized GMT format string for GMT(UTC). gmtZeroFormat)Sets the localized GMT format string for GMT(UTC) itself (GMT offset is 0). |
| public TimeZoneFormat | Returns: this object.the time zone display name data. tznames)Sets the time zone display name data to this instance. |
| private static String[] | Returns: the array of code points in String[]the string str)Break input String into String[]. |
| private static String | Returns: the offset pattern including only hours fieldthe offset pattern including hours and minutes fields offsetHM)Truncates minutes field from the offset pattern with hour/minute |
| private static String | |
| private void |