icu::TimeZoneFormat Class Reference

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

#include <tzfmt.h>

Inheritance diagram for icu::TimeZoneFormat:

icu::Format icu::UObject icu::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.
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).
uint32_t getDefaultParseOptions (void) const
 Returns the bitwise flags of UTimeZoneFormatParseOption representing the default parse options used by this object.
void setDefaultParseOptions (uint32_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

Draft:
This API may be changed in the future versions and was introduced in ICU 50

Definition at line 164 of file tzfmt.h.


Constructor & Destructor Documentation

icu::TimeZoneFormat::TimeZoneFormat ( const TimeZoneFormat other  ) 

Copy constructor.

Draft:
This API may be changed in the future versions and was introduced in ICU 50

virtual icu::TimeZoneFormat::~TimeZoneFormat (  )  [virtual]

Destructor.

Draft:
This API may be changed in the future versions and was introduced in ICU 50

icu::TimeZoneFormat::TimeZoneFormat ( const Locale locale,
UErrorCode status 
) [protected]

Constructs a TimeZoneFormat object for the specified locale.

Parameters:
locale the locale
status receives the status.
Draft:
This API may be changed in the future versions and was introduced in ICU 50


Member Function Documentation

void icu::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:
tznames TimeZoneNames object to be adopted.
Draft:
This API may be changed in the future versions and was introduced in ICU 50

virtual Format* icu::TimeZoneFormat::clone (  )  const [virtual]

Clone this object polymorphically.

The caller is responsible for deleting the result when done.

Returns:
A copy of the object
Draft:
This API may be changed in the future versions and was introduced in ICU 50

Implements icu::Format.

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

Creates an instance of TimeZoneFormat for the given locale.

Parameters:
locale The locale.
status Recevies the status.
Returns:
An instance of TimeZoneFormat for the given locale, owned by the caller.
Draft:
This API may be changed in the future versions and was introduced in ICU 50

virtual UnicodeString& icu::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:
obj The object to format. Must be a TimeZone.
appendTo Output parameter to receive result. Result is appended to existing contents.
pos On input: an alignment field, if desired. On output: the offsets of the alignment field.
status Output param filled with success/failure status.
Returns:
Reference to 'appendTo' parameter.
Draft:
This API may be changed in the future versions and was introduced in ICU 50

Implements icu::Format.

virtual UnicodeString& icu::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:
style The style (e.g. UTZFMT_STYLE_GENERIC_LONG, UTZFMT_STYLE_LOCALIZED_GMT...)
tz The time zone.
date The date.
name Receives the display name.
timeType the 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

Draft:
This API may be changed in the future versions and was introduced in ICU 50

UnicodeString& icu::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:
offset The offset from GMT(UTC) in milliseconds.
result Receives the ISO 8601 style GMT(UTC) offset format.
status Receives the status
Returns:
A reference to the result.
See also:
parseOffsetISO8601
Draft:
This API may be changed in the future versions and was introduced in ICU 50

UnicodeString& icu::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:
offset the offset from GMT(UTC) in milliseconds.
status Receives the status
result Receives the localized GMT format string.
Returns:
A reference to the result.
See also:
parseOffsetLocalizedGMT
Draft:
This API may be changed in the future versions and was introduced in ICU 50

UnicodeString& icu::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:
offset The offset from GMT(UTC) in milliseconds.
result Recevies the RFC822 style GMT(UTC) offset format.
Returns:
A reference to the result.
Parameters:
status Receives the status
See also:
parseOffsetRFC822
Draft:
This API may be changed in the future versions and was introduced in ICU 50

uint32_t icu::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
Draft:
This API may be changed in the future versions and was introduced in ICU 50

virtual UClassID icu::TimeZoneFormat::getDynamicClassID (  )  const [virtual]

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

Draft:
This API may be changed in the future versions and was introduced in ICU 50

Implements icu::UObject.

UnicodeString& icu::TimeZoneFormat::getGMTOffsetDigits ( UnicodeString digits  )  const

Returns the decimal digit characters used for localized GMT format.

The return string contains exactly 10 code points (may include Unicode supplementary character) representing digit 0 to digit 9 in the ascending order.

Parameters:
digits Receives the decimal digits used for localized GMT format.
See also:
setGMTOffsetDigits
Draft:
This API may be changed in the future versions and was introduced in ICU 50

UnicodeString& icu::TimeZoneFormat::getGMTOffsetPattern ( UTimeZoneFormatGMTOffsetPatternType  type,
UnicodeString pattern 
) const

Returns the offset pattern used for localized GMT format.

Parameters:
type The offset pattern type enum.
pattern Receives the offset pattern.
Returns:
A reference to the result pattern.
See also:
setGMTOffsetPattern
Draft:
This API may be changed in the future versions and was introduced in ICU 50

UnicodeString& icu::TimeZoneFormat::getGMTPattern ( UnicodeString pattern  )  const

Returns the localized GMT format pattern.

Parameters:
pattern Receives the localized GMT format pattern.
Returns:
A reference to the result pattern.
See also:
setGMTPattern
Draft:
This API may be changed in the future versions and was introduced in ICU 50

UnicodeString& icu::TimeZoneFormat::getGMTZeroFormat ( UnicodeString gmtZeroFormat  )  const

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

Parameters:
gmtZeroFormat Receives the localized GMT string string for GMT(UTC) itself.
Returns:
A reference to the result GMT string.
See also:
setGMTZeroFormat
Draft:
This API may be changed in the future versions and was introduced in ICU 50

static UClassID icu::TimeZoneFormat::getStaticClassID ( void   )  [static]

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

Draft:
This API may be changed in the future versions and was introduced in ICU 50

const TimeZoneNames* icu::TimeZoneFormat::getTimeZoneNames (  )  const

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

Returns:
The time zone display name data.
Draft:
This API may be changed in the future versions and was introduced in ICU 50

TimeZoneFormat& icu::TimeZoneFormat::operator= ( const TimeZoneFormat other  ) 

Assignment operator.

Draft:
This API may be changed in the future versions and was introduced in ICU 50

virtual UBool icu::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:
other The object to be compared with.
Returns:
Return TRUE if the given Format objects are semantically equal. Objects of different subclasses are considered unequal.
Draft:
This API may be changed in the future versions and was introduced in ICU 50

Implements icu::Format.

TimeZone* icu::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:
text The text contains a time zone string at the position.
style The format style
pos The position.
timeType The 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

Draft:
This API may be changed in the future versions and was introduced in ICU 50

virtual TimeZone* icu::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:
text The text contains a time zone string at the position.
style The format style
pos The position.
parseOptions The parse options repesented by bitwise flags of UTimeZoneFormatParseOption.
timeType The 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

Draft:
This API may be changed in the future versions and was introduced in ICU 50

virtual void icu::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:
source The string to be parsed into an object.
result Formattable to be set to the parse result. If parse fails, return contents are undefined.
parse_pos The 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.
Draft:
This API may be changed in the future versions and was introduced in ICU 50

Implements icu::Format.

int32_t icu::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:
text The text contains ISO8601 style time zone string (e.g. "-08:00", "Z") at the position.
pos The ParsePosition object.
Returns:
The offset from GMT(UTC) in milliseconds for the given ISO 8601 style time zone string.
See also:
formatOffsetISO8601
Draft:
This API may be changed in the future versions and was introduced in ICU 50

int32_t icu::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:
text The text contains a localized GMT offset string at the position.
pos The ParsePosition object.
Returns:
The offset from GMT(UTC) in milliseconds for the given localized GMT offset format string.
See also:
formatOffsetLocalizedGMT
Draft:
This API may be changed in the future versions and was introduced in ICU 50

int32_t icu::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:
text The text contains RFC822 style time zone string (e.g. "-0800") at the position.
pos The ParsePosition object.
Returns:
The offset from GMT(UTC) in milliseconds for the given RFC822 style time zone string.
See also:
formatOffsetRFC822
Draft:
This API may be changed in the future versions and was introduced in ICU 50

void icu::TimeZoneFormat::setDefaultParseOptions ( uint32_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
Draft:
This API may be changed in the future versions and was introduced in ICU 50

void icu::TimeZoneFormat::setGMTOffsetDigits ( const UnicodeString digits,
UErrorCode status 
)

Sets the decimal digit characters used for localized GMT format.

The input digits must contain exactly 10 code points (Unicode supplementary characters are also allowed) representing digit 0 to digit 9 in the ascending order. When the input digits does not satisfy the condition, U_ILLEGAL_ARGUMENT_ERROR will be set to the return status.

Parameters:
digits The decimal digits used for localized GMT format.
status Receives the status.
See also:
getGMTOffsetDigits
Draft:
This API may be changed in the future versions and was introduced in ICU 50

void icu::TimeZoneFormat::setGMTOffsetPattern ( UTimeZoneFormatGMTOffsetPatternType  type,
const UnicodeString pattern,
UErrorCode status 
)

Sets the offset pattern for the given offset type.

Parameters:
type The offset pattern type enum.
pattern The offset pattern used for localized GMT format for the type.
status Receives the status.
See also:
getGMTOffsetPattern
Draft:
This API may be changed in the future versions and was introduced in ICU 50

void icu::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:
pattern The localized GMT format pattern to be used by this object.
status Recieves the status.
See also:
getGMTPattern
Draft:
This API may be changed in the future versions and was introduced in ICU 50

void icu::TimeZoneFormat::setGMTZeroFormat ( const UnicodeString gmtZeroFormat,
UErrorCode status 
)

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

Parameters:
gmtZeroFormat The localized GMT format string for GMT(UTC).
status Receives the status.
See also:
getGMTZeroFormat
Draft:
This API may be changed in the future versions and was introduced in ICU 50

void icu::TimeZoneFormat::setTimeZoneNames ( const TimeZoneNames tznames  ) 

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

Parameters:
tznames TimeZoneNames object to be set.
Draft:
This API may be changed in the future versions and was introduced in ICU 50


The documentation for this class was generated from the following file:
Generated on 25 Nov 2014 for ICU 50.1.2 by  doxygen 1.4.7