|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjava.text.Format
com.ibm.icu.text.UFormat
com.ibm.icu.text.TimeZoneFormat
public class TimeZoneFormat
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,
Serialized Form| Nested Class Summary | |
|---|---|
static class |
TimeZoneFormat.GMTOffsetPatternType
Deprecated. This API might change or be removed in a future release. |
static class |
TimeZoneFormat.Style
Deprecated. This API might change or be removed in a future release. |
static class |
TimeZoneFormat.TimeType
Deprecated. This API might change or be removed in a future release. |
| Nested classes/interfaces inherited from class java.text.Format |
|---|
Format.Field |
| Constructor Summary | |
|---|---|
protected |
TimeZoneFormat(ULocale locale)
Deprecated. This API might change or be removed in a future release. |
| Method Summary | |
|---|---|
TimeZoneFormat |
cloneAsThawed()
Deprecated. This API might change or be removed in a future release. |
StringBuffer |
format(Object obj,
StringBuffer toAppendTo,
FieldPosition pos)
Deprecated. This API might change or be removed in a future release. |
String |
format(TimeZoneFormat.Style style,
TimeZone tz,
long date)
Deprecated. This API might change or be removed in a future release. |
String |
format(TimeZoneFormat.Style style,
TimeZone tz,
long date,
Output<TimeZoneFormat.TimeType> timeType)
Deprecated. This API might change or be removed in a future release. |
String |
formatOffsetLocalizedGMT(int offset)
Deprecated. This API might change or be removed in a future release. |
String |
formatOffsetRFC822(int offset)
Deprecated. This API might change or be removed in a future release. |
AttributedCharacterIterator |
formatToCharacterIterator(Object obj)
Deprecated. This API might change or be removed in a future release. |
TimeZoneFormat |
freeze()
Deprecated. This API might change or be removed in a future release. |
String |
getGMTOffsetDigits()
Deprecated. This API might change or be removed in a future release. |
String |
getGMTOffsetPattern(TimeZoneFormat.GMTOffsetPatternType type)
Deprecated. This API might change or be removed in a future release. |
String |
getGMTPattern()
Deprecated. This API might change or be removed in a future release. |
String |
getGMTZeroFormat()
Deprecated. This API might change or be removed in a future release. |
static TimeZoneFormat |
getInstance(ULocale locale)
Deprecated. This API might change or be removed in a future release. |
TimeZoneNames |
getTimeZoneNames()
Deprecated. This API might change or be removed in a future release. |
boolean |
isFrozen()
Deprecated. This API might change or be removed in a future release. |
boolean |
isParseAllStyles()
Deprecated. This API might change or be removed in a future release. |
TimeZone |
parse(String text)
Deprecated. This API might change or be removed in a future release. |
TimeZone |
parse(String text,
ParsePosition pos)
Deprecated. This API might change or be removed in a future release. |
TimeZone |
parse(TimeZoneFormat.Style style,
String text,
ParsePosition pos,
Output<TimeZoneFormat.TimeType> timeType)
Deprecated. This API might change or be removed in a future release. |
Object |
parseObject(String source,
ParsePosition pos)
Deprecated. This API might change or be removed in a future release. |
int |
parseOffsetLocalizedGMT(String text,
ParsePosition pos)
Deprecated. This API might change or be removed in a future release. |
int |
parseOffsetRFC822(String text,
ParsePosition pos)
Deprecated. This API might change or be removed in a future release. |
TimeZoneFormat |
setGMTOffsetDigits(String digits)
Deprecated. This API might change or be removed in a future release. |
TimeZoneFormat |
setGMTOffsetPattern(TimeZoneFormat.GMTOffsetPatternType type,
String pattern)
Deprecated. This API might change or be removed in a future release. |
TimeZoneFormat |
setGMTPattern(String pattern)
Deprecated. This API might change or be removed in a future release. |
TimeZoneFormat |
setGMTZeroFormat(String gmtZeroFormat)
Deprecated. This API might change or be removed in a future release. |
TimeZoneFormat |
setParseAllStyles(boolean parseAllStyles)
Deprecated. This API might change or be removed in a future release. |
TimeZoneFormat |
setTimeZoneNames(TimeZoneNames tznames)
Deprecated. This API might change or be removed in a future release. |
| Methods inherited from class com.ibm.icu.text.UFormat |
|---|
getLocale |
| Methods inherited from class java.text.Format |
|---|
clone, format, parseObject |
| Methods inherited from class java.lang.Object |
|---|
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
protected TimeZoneFormat(ULocale locale)
locale - the locale| Method Detail |
|---|
public static TimeZoneFormat getInstance(ULocale locale)
TimeZoneFormat for the given locale.
Note: The instance returned by this method is frozen. If you want to
customize a TimeZoneFormat, you must use cloneAsThawed() to get a
thawed copy first.
locale - the locale.
TimeZoneFormat for the given locale.public TimeZoneNames getTimeZoneNames()
setTimeZoneNames(TimeZoneNames)public TimeZoneFormat setTimeZoneNames(TimeZoneNames tznames)
tznames - the time zone display name data.
UnsupportedOperationException - when this object is frozen.getTimeZoneNames()public String getGMTPattern()
setGMTPattern(String)public TimeZoneFormat setGMTPattern(String pattern)
pattern - the localized GMT format pattern string
IllegalArgumentException - when the pattern string does not contain "{0}"
UnsupportedOperationException - when this object is frozen.getGMTPattern()public String getGMTOffsetPattern(TimeZoneFormat.GMTOffsetPatternType type)
type - the offset pattern enum
setGMTOffsetPattern(GMTOffsetPatternType, String)
public TimeZoneFormat setGMTOffsetPattern(TimeZoneFormat.GMTOffsetPatternType type,
String pattern)
type - the offset pettern.pattern - the pattern string.
IllegalArgumentException - when the pattern string does not have required time field letters.
UnsupportedOperationException - when this object is frozen.getGMTOffsetPattern(GMTOffsetPatternType)public String getGMTOffsetDigits()
setGMTOffsetDigits(String)public TimeZoneFormat setGMTOffsetDigits(String digits)
digits - a string contains the decimal digit characters from 0 to 9 n the ascending order.
IllegalArgumentException - when the string did not contain ten characters.
UnsupportedOperationException - when this object is frozen.getGMTOffsetDigits()public String getGMTZeroFormat()
setGMTZeroFormat(String)public TimeZoneFormat setGMTZeroFormat(String gmtZeroFormat)
gmtZeroFormat - the localized GMT format string for GMT(UTC).
UnsupportedOperationException - when this object is frozen.getGMTZeroFormat()public boolean isParseAllStyles()
true when this TimeZoneFormat is configured for parsing
display names including names that are only used by other styles by
parse(Style, String, ParsePosition, Output).
Note: An instance created by getInstance(ULocale) is configured NOT
parsing all styles (false).
true when this instance is configure for parsing all available names.setParseAllStyles(boolean)public TimeZoneFormat setParseAllStyles(boolean parseAllStyles)
parse(Style, String, ParsePosition, Output) to parse display
names including names that are only used by other styles.
parseAllStyles - true to parse all available names.
UnsupportedOperationException - when this object is frozen.isParseAllStyles()public final String formatOffsetRFC822(int offset)
offset - the offset for GMT(UTC) in milliseconds.
parseOffsetRFC822(String, ParsePosition)public String formatOffsetLocalizedGMT(int offset)
getGMTPattern())
getGMTOffsetPattern(GMTOffsetPatternType))
getGMTOffsetDigits())
getGMTZeroFormat())
offset - the offset from GMT(UTC) in milliseconds.
parseOffsetLocalizedGMT(String, ParsePosition)
public final String format(TimeZoneFormat.Style style,
TimeZone tz,
long date)
Note: A style may have fallback styles defined. For example,
when GENERIC_LONG is requested, but there is no display name
data available for GENERIC_LONG style, the implementation
may use GENERIC_LOCATION or LOCALIZED_GMT.
See UTS#35 UNICODE LOCALE DATA MARKUP LANGUAGE (LDML)
Appendix J: Time Zone Display Name
for the details.
style - the style enum (e.g. GENERIC_LONG, LOCALIZED_GMT...)tz - the time zone.date - the date.
TimeZoneFormat.Style,
format(Style, TimeZone, long, Output)
public String format(TimeZoneFormat.Style style,
TimeZone tz,
long date,
Output<TimeZoneFormat.TimeType> timeType)
Output<TimeType> timeType
in addition to the argument list of format(Style, TimeZone, long).
The argument is used for receiving the time type (standard time
or daylight saving time, or unknown) actually used for the display name.
style - the style enum (e.g. GENERIC_LONG, LOCALIZED_GMT...)tz - the time zone.date - the date.timeType - 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.
TimeZoneFormat.Style,
format(Style, TimeZone, long)
public final int parseOffsetRFC822(String text,
ParsePosition pos)
ParsePosition pos and returns 0.
text - the text contains RFC822 style time zone string (e.g. "-0800")
at the position.pos - the position.
formatOffsetRFC822(int)
public int parseOffsetLocalizedGMT(String text,
ParsePosition pos)
ParsePosition pos
and returns 0.
text - the text contains a localized GMT offset string at the position.pos - the position.
formatOffsetLocalizedGMT(int)
public TimeZone parse(TimeZoneFormat.Style style,
String text,
ParsePosition pos,
Output<TimeZoneFormat.TimeType> timeType)
TimeZone by parsing the time zone string according to
the given parse position.
Note: By default, this method supports 1) RFC822 style time zone format,
2) Localized GMT offset format and 3) all display names that are used for the
given style. If you want to parse all display names including names that are
only used for styles other than the specified style, then you should
set true to setParseAllStyles(boolean).
text - the text contains a time zone string at the position.style - the format stylepos - the position.timeType - The output argument for receiving the time type (standard/daylight/unknown),
or specify null if the information is not necessary.
TimeZone, or null if the input could not be parsed.TimeZoneFormat.Style,
format(Style, TimeZone, long, Output),
setParseAllStyles(boolean)
public final TimeZone parse(String text,
ParsePosition pos)
TimeZone by parsing the time zone string according to
the given parse position.
Note: This method is equivalent to parse(Style.GENERIC_LOCATION,
text, pos, null) with setParseAllStyles(true).
text - the text contains a time zone string at the position.pos - the position.
TimeZone, or null if the input could not be parsed.parse(Style, String, ParsePosition, Output)
public final TimeZone parse(String text)
throws ParseException
TimeZone for the given text.
text - the time zone string
TimeZone.
ParseException - when the input could not be parsed as a time zone string.parse(String, ParsePosition),
parse(Style, String, ParsePosition, Output)
public StringBuffer format(Object obj,
StringBuffer toAppendTo,
FieldPosition pos)
format in class Formatpublic AttributedCharacterIterator formatToCharacterIterator(Object obj)
formatToCharacterIterator in class Format
public Object parseObject(String source,
ParsePosition pos)
parseObject in class Formatpublic boolean isFrozen()
isFrozen in interface Freezable<TimeZoneFormat>public TimeZoneFormat freeze()
freeze in interface Freezable<TimeZoneFormat>public TimeZoneFormat cloneAsThawed()
cloneAsThawed in interface Freezable<TimeZoneFormat>
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||