ICU 49.1.1  49.1.1
Public Member Functions | Static Public Member Functions | Protected Member Functions
TimeZoneFormat Class Reference

TimeZoneFormat supports time zone display name formatting and parsing. More...

#include <tzfmt.h>

Inheritance diagram for TimeZoneFormat:
Format UObject UMemory

Public Member Functions

 TimeZoneFormat (const TimeZoneFormat &other)
 Copy constructor.
virtual ~TimeZoneFormat ()
 Destructor.
TimeZoneFormatoperator= (const TimeZoneFormat &other)
 Assignment operator.
virtual UBool operator== (const Format &other) const
 Return true if the given Format objects are semantically equal.
virtual Formatclone () const
 Clone this object polymorphically.
const TimeZoneNamesgetTimeZoneNames () const
 Returns the time zone display name data used by this instance.
void adoptTimeZoneNames (TimeZoneNames *tznames)
 Sets the time zone display name data to this format instnace.
void setTimeZoneNames (const TimeZoneNames &tznames)
 Sets the time zone display name data to this format instnace.
UnicodeStringgetGMTPattern (UnicodeString &pattern) const
 Returns the localized GMT format pattern.
void setGMTPattern (const UnicodeString &pattern, UErrorCode &status)
 Sets the localized GMT format pattern.
UnicodeStringgetGMTOffsetPattern (UTimeZoneFormatGMTOffsetPatternType type, UnicodeString &pattern) const
 Returns the offset pattern used for localized GMT format.
void setGMTOffsetPattern (UTimeZoneFormatGMTOffsetPatternType type, const UnicodeString &pattern, UErrorCode &status)
 Sets the offset pattern for the given offset type.
UnicodeStringgetGMTOffsetDigits (UnicodeString &digits) const
 Returns the decimal digit characters used for localized GMT format in a single string containing from 0 to 9 in the ascending order.
void setGMTOffsetDigits (const UnicodeString &digits, UErrorCode &status)
 Sets the decimal digit characters used for localized GMT format.
UnicodeStringgetGMTZeroFormat (UnicodeString &gmtZeroFormat) const
 Returns the localized GMT format string for GMT(UTC) itself (GMT offset is 0).
void setGMTZeroFormat (const UnicodeString &gmtZeroFormat, UErrorCode &status)
 Sets the localized GMT format string for GMT(UTC) itself (GMT offset is 0).
int32_t getDefaultParseOptions (void) const
 Returns the bitwise flags of UTimeZoneFormatParseOption representing the default parse options used by this object.
void setDefaultParseOptions (int32_t flags)
 Sets the default parse options.
UnicodeStringformatOffsetRFC822 (int32_t offset, UnicodeString &result, UErrorCode &status) const
 Returns the RFC822 style time zone string for the given offset.
UnicodeStringformatOffsetISO8601 (int32_t offset, UnicodeString &result, UErrorCode &status) const
 Returns the ISO 8601 style time zone string for the given offset.
UnicodeStringformatOffsetLocalizedGMT (int32_t offset, UnicodeString &result, UErrorCode &status) const
 Returns the localized GMT(UTC) offset format for the given offset.
virtual UnicodeStringformat (UTimeZoneFormatStyle style, const TimeZone &tz, UDate date, UnicodeString &name, UTimeZoneFormatTimeType *timeType=NULL) const
 Returns the display name of the time zone at the given date for the style.
int32_t parseOffsetRFC822 (const UnicodeString &text, ParsePosition &pos) const
 Returns offset from GMT(UTC) in milliseconds for the given RFC822 style time zone string.
int32_t parseOffsetISO8601 (const UnicodeString &text, ParsePosition &pos) const
 Returns offset from GMT(UTC) in milliseconds for the given ISO 8601 style time zone string.
int32_t parseOffsetLocalizedGMT (const UnicodeString &text, ParsePosition &pos) const
 Returns offset from GMT(UTC) in milliseconds for the given localized GMT offset format string.
virtual TimeZoneparse (UTimeZoneFormatStyle style, const UnicodeString &text, ParsePosition &pos, int32_t parseOptions, UTimeZoneFormatTimeType *timeType=NULL) const
 Returns a TimeZone by parsing the time zone string according to the given parse position, the specified format style and parse options.
TimeZoneparse (UTimeZoneFormatStyle style, const UnicodeString &text, ParsePosition &pos, UTimeZoneFormatTimeType *timeType=NULL) const
 Returns a TimeZone by parsing the time zone string according to the given parse position, the specified format style and the default parse options.
virtual UnicodeStringformat (const Formattable &obj, UnicodeString &appendTo, FieldPosition &pos, UErrorCode &status) const
 Format an object to produce a time zone display string using localized GMT offset format.
virtual void parseObject (const UnicodeString &source, Formattable &result, ParsePosition &parse_pos) const
 Parse a string to produce an object.
virtual UClassID getDynamicClassID () const
 ICU "poor man's RTTI", returns a UClassID for the actual class.

Static Public Member Functions

static TimeZoneFormatcreateInstance (const Locale &locale, UErrorCode &status)
 Creates an instance of TimeZoneFormat for the given locale.
static UClassID getStaticClassID (void)
 ICU "poor man's RTTI", returns a UClassID for this class.

Protected Member Functions

 TimeZoneFormat (const Locale &locale, UErrorCode &status)
 Constructs a TimeZoneFormat object for the specified locale.

Detailed Description

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.

See also:
SimpleDateFormat
TimeZoneNames
Internal:
Do not use. This API is for internal use only. ICU 49 technology preview

Definition at line 166 of file tzfmt.h.


Constructor & Destructor Documentation

TimeZoneFormat::TimeZoneFormat ( const TimeZoneFormat other)

Copy constructor.

Internal:
Do not use. This API is for internal use only. ICU 49 technology preview
virtual TimeZoneFormat::~TimeZoneFormat ( ) [virtual]

Destructor.

Internal:
Do not use. This API is for internal use only. ICU 49 technology preview
TimeZoneFormat::TimeZoneFormat ( const Locale locale,
UErrorCode status 
) [protected]

Constructs a TimeZoneFormat object for the specified locale.

Parameters:
localethe locale
statusreceives the status.
Internal:
Do not use. This API is for internal use only. ICU 49 technology preview

Member Function Documentation

void TimeZoneFormat::adoptTimeZoneNames ( TimeZoneNames tznames)

Sets the time zone display name data to this format instnace.

The caller should not delete the TimeZoenNames object after it is adopted by this call.

Parameters:
tznamesTimeZoneNames object to be adopted.
Internal:
Do not use. This API is for internal use only. ICU 49 technology preview
virtual Format* TimeZoneFormat::clone ( ) const [virtual]

Clone this object polymorphically.

The caller is responsible for deleting the result when done.

Returns:
A copy of the object
Internal:
Do not use. This API is for internal use only. ICU 49 technology preview

Implements Format.

static TimeZoneFormat* TimeZoneFormat::createInstance ( const Locale locale,
UErrorCode status 
) [static]

Creates an instance of TimeZoneFormat for the given locale.

Parameters:
localeThe locale.
statusRecevies the status.
Returns:
An instance of TimeZoneFormat for the given locale, owned by the caller.
Internal:
Do not use. This API is for internal use only. ICU 49 technology preview
virtual UnicodeString& TimeZoneFormat::format ( UTimeZoneFormatStyle  style,
const TimeZone tz,
UDate  date,
UnicodeString name,
UTimeZoneFormatTimeType timeType = NULL 
) const [virtual]

Returns the display name of the time zone at the given date for the style.

Parameters:
styleThe style (e.g. UTZFMT_STYLE_GENERIC_LONG, UTZFMT_STYLE_LOCALIZED_GMT...)
tzThe time zone.
dateThe date.
nameReceives the display name.
timeTypethe output argument for receiving the time type (standard/daylight/unknown) used for the display name, or NULL if the information is not necessary.
Returns:
A reference to the result
See also:
UTimeZoneFormatStyle
UTimeZoneFormatTimeType
Internal:
Do not use. This API is for internal use only. ICU 49 technology preview
virtual UnicodeString& TimeZoneFormat::format ( const Formattable obj,
UnicodeString appendTo,
FieldPosition pos,
UErrorCode status 
) const [virtual]

Format an object to produce a time zone display string using localized GMT offset format.

This method handles Formattable objects with a TimeZone. If a the Formattable object type is not a TimeZone, then it returns a failing UErrorCode.

Parameters:
objThe object to format. Must be a TimeZone.
appendToOutput parameter to receive result. Result is appended to existing contents.
posOn input: an alignment field, if desired. On output: the offsets of the alignment field.
statusOutput param filled with success/failure status.
Returns:
Reference to 'appendTo' parameter.
Internal:
Do not use. This API is for internal use only. ICU 49 technology preview

Implements Format.

UnicodeString& TimeZoneFormat::formatOffsetISO8601 ( int32_t  offset,
UnicodeString result,
UErrorCode status 
) const

Returns the ISO 8601 style time zone string for the given offset.

For example, "-08:00" and "Z".

Parameters:
offsetThe offset from GMT(UTC) in milliseconds.
resultRecevies the ISO 8601 style GMT(UTC) offset format.
Returns:
A reference to the result.
See also:
parseOffsetISO8601
Internal:
Do not use. This API is for internal use only. ICU 49 technology preview
UnicodeString& TimeZoneFormat::formatOffsetLocalizedGMT ( int32_t  offset,
UnicodeString result,
UErrorCode status 
) const

Returns the localized GMT(UTC) offset format for the given offset.

The localized GMT offset is defined by;

Parameters:
offsetthe offset from GMT(UTC) in milliseconds.
resultReceives the localized GMT format string.
Returns:
A reference to the result.
See also:
parseOffsetLocalizedGMT
Internal:
Do not use. This API is for internal use only. ICU 49 technology preview
UnicodeString& TimeZoneFormat::formatOffsetRFC822 ( int32_t  offset,
UnicodeString result,
UErrorCode status 
) const

Returns the RFC822 style time zone string for the given offset.

For example, "-0800".

Parameters:
offsetThe offset from GMT(UTC) in milliseconds.
resultRecevies the RFC822 style GMT(UTC) offset format.
Returns:
A reference to the result.
See also:
parseOffsetRFC822
Internal:
Do not use. This API is for internal use only. ICU 49 technology preview
int32_t TimeZoneFormat::getDefaultParseOptions ( void  ) const

Returns the bitwise flags of UTimeZoneFormatParseOption representing the default parse options used by this object.

Returns:
the default parse options.
See also:
ParseOption
Internal:
Do not use. This API is for internal use only. ICU 49 technology preview
virtual UClassID TimeZoneFormat::getDynamicClassID ( ) const [virtual]

ICU "poor man's RTTI", returns a UClassID for the actual class.

Internal:
Do not use. This API is for internal use only. ICU 49 technology preview

Implements UObject.

UnicodeString& TimeZoneFormat::getGMTOffsetDigits ( UnicodeString digits) const

Returns the decimal digit characters used for localized GMT format in a single string containing from 0 to 9 in the ascending order.

Parameters:
digitsReceives the decimal digits used for localized GMT format.
See also:
setGMTOffsetDigits
UnicodeString& TimeZoneFormat::getGMTOffsetPattern ( UTimeZoneFormatGMTOffsetPatternType  type,
UnicodeString pattern 
) const

Returns the offset pattern used for localized GMT format.

Parameters:
typeThe offset pattern type enum.
patternReceives the offset pattern.
Returns:
A reference to the result pattern.
See also:
setGMTOffsetPattern
Internal:
Do not use. This API is for internal use only. ICU 49 technology preview
UnicodeString& TimeZoneFormat::getGMTPattern ( UnicodeString pattern) const

Returns the localized GMT format pattern.

Parameters:
patternReceives the localized GMT format pattern.
Returns:
A reference to the result pattern.
See also:
setGMTPattern
Internal:
Do not use. This API is for internal use only. ICU 49 technology preview
UnicodeString& TimeZoneFormat::getGMTZeroFormat ( UnicodeString gmtZeroFormat) const

Returns the localized GMT format string for GMT(UTC) itself (GMT offset is 0).

Parameters:
gmtZeroFormatReceives the localized GMT string string for GMT(UTC) itself.
Returns:
A reference to the result GMT string.
See also:
setGMTZeroFormat
static UClassID TimeZoneFormat::getStaticClassID ( void  ) [static]

ICU "poor man's RTTI", returns a UClassID for this class.

Internal:
Do not use. This API is for internal use only. ICU 49 technology preview
const TimeZoneNames* TimeZoneFormat::getTimeZoneNames ( ) const

Returns the time zone display name data used by this instance.

Returns:
The time zone display name data.
Internal:
Do not use. This API is for internal use only. ICU 49 technology preview
TimeZoneFormat& TimeZoneFormat::operator= ( const TimeZoneFormat other)

Assignment operator.

Internal:
Do not use. This API is for internal use only. ICU 49 technology preview
virtual UBool TimeZoneFormat::operator== ( const Format other) const [virtual]

Return true if the given Format objects are semantically equal.

Objects of different subclasses are considered unequal.

Parameters:
otherThe object to be compared with.
Returns:
Return TRUE if the given Format objects are semantically equal. Objects of different subclasses are considered unequal.
Internal:
Do not use. This API is for internal use only. ICU 49 technology preview

Implements Format.

virtual TimeZone* TimeZoneFormat::parse ( UTimeZoneFormatStyle  style,
const UnicodeString text,
ParsePosition pos,
int32_t  parseOptions,
UTimeZoneFormatTimeType timeType = NULL 
) const [virtual]

Returns a TimeZone by parsing the time zone string according to the given parse position, the specified format style and parse options.

Parameters:
textThe text contains a time zone string at the position.
styleThe format style
posThe position.
parseOptionsThe parse options repesented by bitwise flags of UTimeZoneFormatParseOption.
timeTypeThe output argument for receiving the time type (standard/daylight/unknown), or NULL if the information is not necessary.
Returns:
A TimeZone, or null if the input could not be parsed.
See also:
UTimeZoneFormatStyle
UTimeZoneFormatParseOption
UTimeZoneFormatTimeType
Internal:
Do not use. This API is for internal use only. ICU 49 technology preview
TimeZone* TimeZoneFormat::parse ( UTimeZoneFormatStyle  style,
const UnicodeString text,
ParsePosition pos,
UTimeZoneFormatTimeType timeType = NULL 
) const

Returns a TimeZone by parsing the time zone string according to the given parse position, the specified format style and the default parse options.

Parameters:
textThe text contains a time zone string at the position.
styleThe format style
posThe position.
timeTypeThe output argument for receiving the time type (standard/daylight/unknown), or NULL if the information is not necessary.
Returns:
A TimeZone, or null if the input could not be parsed.
See also:
UTimeZoneFormatStyle
UTimeZoneFormatParseOption
UTimeZoneFormatTimeType
Internal:
Do not use. This API is for internal use only. ICU 49 technology preview
virtual void TimeZoneFormat::parseObject ( const UnicodeString source,
Formattable result,
ParsePosition parse_pos 
) const [virtual]

Parse a string to produce an object.

This methods handles parsing of time zone display strings into Formattable objects with TimeZone.

Parameters:
sourceThe string to be parsed into an object.
resultFormattable to be set to the parse result. If parse fails, return contents are undefined.
parse_posThe position to start parsing at. Upon return this param is set to the position after the last character successfully parsed. If the source is not parsed successfully, this param will remain unchanged.
Returns:
A newly created Formattable* object, or NULL on failure. The caller owns this and should delete it when done.
Internal:
Do not use. This API is for internal use only. ICU 49 technology preview

Implements Format.

int32_t TimeZoneFormat::parseOffsetISO8601 ( const UnicodeString text,
ParsePosition pos 
) const

Returns offset from GMT(UTC) in milliseconds for the given ISO 8601 style time zone string.

When the given string is not an ISO 8601 time zone string, this method sets the current position as the error index to ParsePosition pos and returns 0.

Parameters:
textThe text contains RFC822 style time zone string (e.g. "-08:00", "Z") at the position.
posThe ParsePosition object.
Returns:
The offset from GMT(UTC) in milliseconds for the given ISO 8601 style time zone string.
See also:
formatOffsetISO8601
Internal:
Do not use. This API is for internal use only. ICU 49 technology preview
int32_t TimeZoneFormat::parseOffsetLocalizedGMT ( const UnicodeString text,
ParsePosition pos 
) const

Returns offset from GMT(UTC) in milliseconds for the given localized GMT offset format string.

When the given string cannot be parsed, this method sets the current position as the error index to ParsePosition pos and returns 0.

Parameters:
textThe text contains a localized GMT offset string at the position.
posThe ParsePosition object.
Returns:
The offset from GMT(UTC) in milliseconds for the given localized GMT offset format string.
See also:
formatOffsetLocalizedGMT
Internal:
Do not use. This API is for internal use only. ICU 49 technology preview
int32_t TimeZoneFormat::parseOffsetRFC822 ( const UnicodeString text,
ParsePosition pos 
) const

Returns offset from GMT(UTC) in milliseconds for the given RFC822 style time zone string.

When the given string is not an RFC822 time zone string, this method sets the current position as the error index to ParsePosition pos and returns 0.

Parameters:
textThe text contains RFC822 style time zone string (e.g. "-0800") at the position.
posThe ParsePosition object.
Returns:
The offset from GMT(UTC) in milliseconds for the given RFC822 style time zone string.
See also:
formatOffsetRFC822
Internal:
Do not use. This API is for internal use only. ICU 49 technology preview
void TimeZoneFormat::setDefaultParseOptions ( int32_t  flags)

Sets the default parse options.

Note: By default, an instance of TimeZoneFormat created by createInstance has no parse options set (UTZFMT_PARSE_OPTION_NONE). To specify multipe options, use bitwise flags of UTimeZoneFormatParseOption.

See also:
UTimeZoneFormatParseOption
Internal:
Do not use. This API is for internal use only. ICU 49 technology preview
void TimeZoneFormat::setGMTOffsetDigits ( const UnicodeString digits,
UErrorCode status 
)

Sets the decimal digit characters used for localized GMT format.

Parameters:
digitsThe decimal digits used for localized GMT format.
statusReceives the status.
See also:
getGMTOffsetDigits
void TimeZoneFormat::setGMTOffsetPattern ( UTimeZoneFormatGMTOffsetPatternType  type,
const UnicodeString pattern,
UErrorCode status 
)

Sets the offset pattern for the given offset type.

Parameters:
typeThe offset pattern type enum.
patternThe offset pattern used for localized GMT format for the type.
statusReceives the status.
See also:
getGMTOffsetPattern
Internal:
Do not use. This API is for internal use only. ICU 49 technology preview
void TimeZoneFormat::setGMTPattern ( const UnicodeString pattern,
UErrorCode status 
)

Sets the localized GMT format pattern.

The pattern must contain a single argument {0}, for example "GMT {0}".

Parameters:
patternThe localized GMT format pattern to be used by this object.
statusRecieves the status.
See also:
getGMTPattern
Internal:
Do not use. This API is for internal use only. ICU 49 technology preview
void TimeZoneFormat::setGMTZeroFormat ( const UnicodeString gmtZeroFormat,
UErrorCode status 
)

Sets the localized GMT format string for GMT(UTC) itself (GMT offset is 0).

Parameters:
gmtZeroFormatThe localized GMT format string for GMT(UTC).
statusReceives the status.
See also:
getGMTZeroFormat
void TimeZoneFormat::setTimeZoneNames ( const TimeZoneNames tznames)

Sets the time zone display name data to this format instnace.

Parameters:
tznamesTimeZoneNames object to be set.
Internal:
Do not use. This API is for internal use only. ICU 49 technology preview

The documentation for this class was generated from the following file: