DateFormatSymbols Class Reference

DateFormatSymbols is a public class for encapsulating localizable date-time formatting data -- including timezone data. More...

#include <dtfmtsym.h>

Inheritance diagram for DateFormatSymbols:

UObject UMemory

Public Types

enum  DtContextType { FORMAT, STANDALONE, DT_CONTEXT_COUNT }
 Selector for date formatting context. More...
enum  DtWidthType { ABBREVIATED, WIDE, NARROW, DT_WIDTH_COUNT }
 Selector for date formatting width. More...
enum  TimeZoneTranslationType {
  TIMEZONE_SHORT_GENERIC, TIMEZONE_SHORT_STANDARD, TIMEZONE_SHORT_DAYLIGHT, TIMEZONE_LONG_GENERIC,
  TIMEZONE_LONG_STANDARD, TIMEZONE_LONG_DAYLIGHT, TIMEZONE_EXEMPLAR_CITY, TIMEZONE_COUNT
}
 The translation type of the translated zone strings. More...

Public Member Functions

 DateFormatSymbols (UErrorCode &status)
 Construct a DateFormatSymbols object by loading format data from resources for the default locale, in the default calendar (Gregorian).
 DateFormatSymbols (const Locale &locale, UErrorCode &status)
 Construct a DateFormatSymbols object by loading format data from resources for the given locale, in the default calendar (Gregorian).
 DateFormatSymbols (const char *type, UErrorCode &status)
 Construct a DateFormatSymbols object by loading format data from resources for the default locale, in the default calendar (Gregorian).
 DateFormatSymbols (const Locale &locale, const char *type, UErrorCode &status)
 Construct a DateFormatSymbols object by loading format data from resources for the given locale, in the default calendar (Gregorian).
 DateFormatSymbols (const DateFormatSymbols &)
 Copy constructor.
DateFormatSymbolsoperator= (const DateFormatSymbols &)
 Assignment operator.
virtual ~DateFormatSymbols ()
 Destructor.
UBool operator== (const DateFormatSymbols &other) const
 Return true if another object is semantically equal to this one.
UBool operator!= (const DateFormatSymbols &other) const
 Return true if another object is semantically unequal to this one.
const UnicodeStringgetEras (int32_t &count) const
 Gets era strings.
void setEras (const UnicodeString *eras, int32_t count)
 Sets era strings.
const UnicodeStringgetEraNames (int32_t &count) const
 Gets era name strings.
void setEraNames (const UnicodeString *eraNames, int32_t count)
 Sets era name strings.
const UnicodeStringgetMonths (int32_t &count) const
 Gets month strings.
void setMonths (const UnicodeString *months, int32_t count)
 Sets month strings.
const UnicodeStringgetShortMonths (int32_t &count) const
 Gets short month strings.
void setShortMonths (const UnicodeString *shortMonths, int32_t count)
 Sets short month strings.
const UnicodeStringgetMonths (int32_t &count, DtContextType context, DtWidthType width) const
 Gets month strings by width and context.
void setMonths (const UnicodeString *months, int32_t count, DtContextType context, DtWidthType width)
 Sets month strings by width and context.
const UnicodeStringgetWeekdays (int32_t &count) const
 Gets weekday strings.
void setWeekdays (const UnicodeString *weekdays, int32_t count)
 Sets weekday strings.
const UnicodeStringgetShortWeekdays (int32_t &count) const
 Gets short weekday strings.
void setShortWeekdays (const UnicodeString *shortWeekdays, int32_t count)
 Sets short weekday strings.
const UnicodeStringgetWeekdays (int32_t &count, DtContextType context, DtWidthType width) const
 Gets weekday strings by width and context.
void setWeekdays (const UnicodeString *weekdays, int32_t count, DtContextType context, DtWidthType width)
 Sets weekday strings by width and context.
const UnicodeStringgetQuarters (int32_t &count, DtContextType context, DtWidthType width) const
 Gets quarter strings by width and context.
void setQuarters (const UnicodeString *quarters, int32_t count, DtContextType context, DtWidthType width)
 Sets quarter strings by width and context.
const UnicodeStringgetAmPmStrings (int32_t &count) const
 Gets AM/PM strings.
void setAmPmStrings (const UnicodeString *ampms, int32_t count)
 Sets ampm strings.
const UnicodeString ** getZoneStrings (int32_t &rowCount, int32_t &columnCount) const
 Gets timezone strings.
void setZoneStrings (const UnicodeString *const *strings, int32_t rowCount, int32_t columnCount)
 Sets timezone strings.
UnicodeStringgetLocalPatternChars (UnicodeString &result) const
 Gets localized date-time pattern characters.
void setLocalPatternChars (const UnicodeString &newLocalPatternChars)
 Sets localized date-time pattern characters.
Locale getLocale (ULocDataLocaleType type, UErrorCode &status) const
 Returns the locale for this object.
virtual UClassID getDynamicClassID () const
 ICU "poor man's RTTI", returns a UClassID for the actual class.
virtual StringEnumerationcreateZoneStringIDs (UErrorCode &status)
 Creates an enumeration of time zone IDs.
UnicodeStringgetZoneString (const UnicodeString &ID, const TimeZoneTranslationType type, UnicodeString &result, UErrorCode &status)
 Gets timezone string give the key and translation type.
void setZoneString (const UnicodeString &ID, const TimeZoneTranslationType type, const UnicodeString &value, UErrorCode &status)
 Sets timezone string for the given the ID and translation type.

Static Public Member Functions

const UChar * getPatternUChars (void)
 Get the non-localized date-time pattern characters.
UClassID getStaticClassID ()
 ICU "poor man's RTTI", returns a UClassID for this class.

Friends

class SimpleDateFormat
class DateFormatSymbolsSingleSetter

Detailed Description

DateFormatSymbols is a public class for encapsulating localizable date-time formatting data -- including timezone data.

DateFormatSymbols is used by DateFormat and SimpleDateFormat.

Rather than first creating a DateFormatSymbols to get a date-time formatter by using a SimpleDateFormat constructor, clients are encouraged to create a date-time formatter using the getTimeInstance(), getDateInstance(), or getDateTimeInstance() method in DateFormat. Each of these methods can return a date/time formatter initialized with a default format pattern along with the date-time formatting data for a given or default locale. After a formatter is created, clients may modify the format pattern using the setPattern function as so desired. For more information on using these formatter factory functions, see DateFormat.

If clients decide to create a date-time formatter with a particular format pattern and locale, they can do so with new SimpleDateFormat(aPattern, new DateFormatSymbols(aLocale)). This will load the appropriate date-time formatting data from the locale.

DateFormatSymbols objects are clonable. When clients obtain a DateFormatSymbols object, they can feel free to modify the date-time formatting data as necessary. For instance, clients can replace the localized date-time format pattern characters with the ones that they feel easy to remember. Or they can change the representative cities originally picked by default to using their favorite ones.

DateFormatSymbols are not expected to be subclassed. Data for a calendar is loaded out of resource bundles. The 'type' parameter indicates the type of calendar, for example, "gregorian" or "japanese". If the type is not gregorian (or NULL, or an empty string) then the type is appended to the resource name, for example, 'Eras_japanese' instead of 'Eras'. If the resource 'Eras_japanese' did not exist (even in root), then this class will fall back to just 'Eras', that is, Gregorian data. Therefore, the calendar implementor MUST ensure that the root locale at least contains any resources that are to be particularized for the calendar type.

Definition at line 77 of file dtfmtsym.h.


Member Enumeration Documentation

enum DateFormatSymbols::DtContextType
 

Selector for date formatting context.

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

Definition at line 269 of file dtfmtsym.h.

enum DateFormatSymbols::DtWidthType
 

Selector for date formatting width.

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

Definition at line 280 of file dtfmtsym.h.

enum DateFormatSymbols::TimeZoneTranslationType
 

The translation type of the translated zone strings.

Internal:
Do not use. This API is for interal use only. ICU 3.6

Definition at line 487 of file dtfmtsym.h.


Constructor & Destructor Documentation

DateFormatSymbols::DateFormatSymbols UErrorCode status  ) 
 

Construct a DateFormatSymbols object by loading format data from resources for the default locale, in the default calendar (Gregorian).

NOTE: This constructor will never fail; if it cannot get resource data for the default locale, it will return a last-resort object based on hard-coded strings.

Parameters:
status Status code. Failure results if the resources for the default cannot be found or cannot be loaded

Stable:
ICU 2.0

DateFormatSymbols::DateFormatSymbols const Locale locale,
UErrorCode status
 

Construct a DateFormatSymbols object by loading format data from resources for the given locale, in the default calendar (Gregorian).

Parameters:
locale Locale to load format data from.
status Status code. Failure results if the resources for the locale cannot be found or cannot be loaded

Stable:
ICU 2.0

DateFormatSymbols::DateFormatSymbols const char *  type,
UErrorCode status
 

Construct a DateFormatSymbols object by loading format data from resources for the default locale, in the default calendar (Gregorian).

NOTE: This constructor will never fail; if it cannot get resource data for the default locale, it will return a last-resort object based on hard-coded strings.

Parameters:
type Type of calendar (as returned by Calendar::getType). Will be used to access the correct set of strings. (NULL or empty string defaults to "gregorian".)
status Status code. Failure results if the resources for the default cannot be found or cannot be loaded
Internal:
Do not use. This API is for interal use only.

DateFormatSymbols::DateFormatSymbols const Locale locale,
const char *  type,
UErrorCode status
 

Construct a DateFormatSymbols object by loading format data from resources for the given locale, in the default calendar (Gregorian).

Parameters:
locale Locale to load format data from.
type Type of calendar (as returned by Calendar::getType). Will be used to access the correct set of strings. (NULL or empty string defaults to "gregorian".)
status Status code. Failure results if the resources for the locale cannot be found or cannot be loaded
Internal:
Do not use. This API is for interal use only.

DateFormatSymbols::DateFormatSymbols const DateFormatSymbols  ) 
 

Copy constructor.

Stable:
ICU 2.0

virtual DateFormatSymbols::~DateFormatSymbols  )  [virtual]
 

Destructor.

This is nonvirtual because this class is not designed to be subclassed.

Stable:
ICU 2.0


Member Function Documentation

virtual StringEnumeration* DateFormatSymbols::createZoneStringIDs UErrorCode status  )  [virtual]
 

Creates an enumeration of time zone IDs.

The object is owned by the caller and should delete it after use. The time zone IDs are just for programmatic lookup. NOT LOCALIZED!!!

Parameters:
status Input/output parameter, set to success or failure code upon return.
Returns:
A new StringEnumeration object

Internal:
Do not use. This API is for interal use only. ICU 3.6

const UnicodeString* DateFormatSymbols::getAmPmStrings int32_t &  count  )  const
 

Gets AM/PM strings.

For example: "AM" and "PM".

Parameters:
count Filled in with length of the array.
Returns:
the weekday strings. (DateFormatSymbols retains ownership.)

Stable:
ICU 2.0

virtual UClassID DateFormatSymbols::getDynamicClassID  )  const [virtual]
 

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

Stable:
ICU 2.2

Implements UObject.

const UnicodeString* DateFormatSymbols::getEraNames int32_t &  count  )  const
 

Gets era name strings.

For example: "Anno Domini" and "Before Christ".

Parameters:
count Filled in with length of the array.
Returns:
the era name strings.

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

const UnicodeString* DateFormatSymbols::getEras int32_t &  count  )  const
 

Gets era strings.

For example: "AD" and "BC".

Parameters:
count Filled in with length of the array.
Returns:
the era strings.

Stable:
ICU 2.0

Locale DateFormatSymbols::getLocale ULocDataLocaleType  type,
UErrorCode status
const
 

Returns the locale for this object.

Two flavors are available: valid and actual locale.

Stable:
ICU 2.8

UnicodeString& DateFormatSymbols::getLocalPatternChars UnicodeString result  )  const
 

Gets localized date-time pattern characters.

For example: 'u', 't', etc.

Parameters:
result Output param which will receive the localized date-time pattern characters.
Returns:
A reference to 'result'.

Stable:
ICU 2.0

const UnicodeString* DateFormatSymbols::getMonths int32_t &  count,
DtContextType  context,
DtWidthType  width
const
 

Gets month strings by width and context.

For example: "January", "February", etc.

Parameters:
count Filled in with length of the array.
context The formatting context, either FORMAT or STANDALONE
width The width of returned strings, either WIDE, ABBREVIATED, or NARROW.
Returns:
the month strings. (DateFormatSymbols retains ownership.)

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

const UnicodeString* DateFormatSymbols::getMonths int32_t &  count  )  const
 

Gets month strings.

For example: "January", "February", etc.

Parameters:
count Filled in with length of the array.
Returns:
the month strings. (DateFormatSymbols retains ownership.)

Stable:
ICU 2.0

const UChar* DateFormatSymbols::getPatternUChars void   )  [static]
 

Get the non-localized date-time pattern characters.

Returns:
the non-localized date-time pattern characters

Stable:
ICU 2.0

const UnicodeString* DateFormatSymbols::getQuarters int32_t &  count,
DtContextType  context,
DtWidthType  width
const
 

Gets quarter strings by width and context.

For example: "1st Quarter", "2nd Quarter", etc.

Parameters:
count Filled in with length of the array.
context The formatting context, either FORMAT or STANDALONE
width The width of returned strings, either WIDE or ABBREVIATED. There are no NARROW quarters.
Returns:
the quarter strings. (DateFormatSymbols retains ownership.)

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

const UnicodeString* DateFormatSymbols::getShortMonths int32_t &  count  )  const
 

Gets short month strings.

For example: "Jan", "Feb", etc.

Parameters:
count Filled in with length of the array.
Returns:
the short month strings. (DateFormatSymbols retains ownership.)

Stable:
ICU 2.0

const UnicodeString* DateFormatSymbols::getShortWeekdays int32_t &  count  )  const
 

Gets short weekday strings.

For example: "Sun", "Mon", etc.

Parameters:
count Filled in with length of the array.
Returns:
the short weekday strings. (DateFormatSymbols retains ownership.)

Stable:
ICU 2.0

UClassID DateFormatSymbols::getStaticClassID  )  [static]
 

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

Stable:
ICU 2.2

const UnicodeString* DateFormatSymbols::getWeekdays int32_t &  count,
DtContextType  context,
DtWidthType  width
const
 

Gets weekday strings by width and context.

For example: "Sunday", "Monday", etc.

Parameters:
count Filled in with length of the array.
context The formatting context, either FORMAT or STANDALONE
width The width of returned strings, either WIDE, ABBREVIATED, or NARROW
Returns:
the month strings. (DateFormatSymbols retains ownership.)

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

const UnicodeString* DateFormatSymbols::getWeekdays int32_t &  count  )  const
 

Gets weekday strings.

For example: "Sunday", "Monday", etc.

Parameters:
count Filled in with length of the array.
Returns:
the weekday strings. (DateFormatSymbols retains ownership.)

Stable:
ICU 2.0

UnicodeString& DateFormatSymbols::getZoneString const UnicodeString ID,
const TimeZoneTranslationType  type,
UnicodeString result,
UErrorCode status
 

Gets timezone string give the key and translation type.

Parameters:
ID The ID of zone strings, e.g: "America/Los_Angeles". The time zone ID is for programmatic lookup.
type The translation type requested
result Output parameter to recieve the translation string
status Input/output parameter, set to success or failure code upon return.
Returns:
the input UnicodeString parameter for chaining

Internal:
Do not use. This API is for interal use only. ICU 3.6

const UnicodeString** DateFormatSymbols::getZoneStrings int32_t &  rowCount,
int32_t &  columnCount
const
 

Gets timezone strings.

These strings are stored in a 2-dimensional array.

Parameters:
rowCount Output param to receive number of rows.
columnCount Output param to receive number of columns.
Returns:
The timezone strings as a 2-d array. (DateFormatSymbols retains ownership.)

Deprecated:
ICU 3.6

UBool DateFormatSymbols::operator!= const DateFormatSymbols other  )  const [inline]
 

Return true if another object is semantically unequal to this one.

Parameters:
other the DateFormatSymbols object to be compared with.
Returns:
true if other is semantically unequal to this.

Stable:
ICU 2.0

Definition at line 186 of file dtfmtsym.h.

DateFormatSymbols& DateFormatSymbols::operator= const DateFormatSymbols  ) 
 

Assignment operator.

Stable:
ICU 2.0

UBool DateFormatSymbols::operator== const DateFormatSymbols other  )  const
 

Return true if another object is semantically equal to this one.

Parameters:
other the DateFormatSymbols object to be compared with.
Returns:
true if other is semantically equal to this.

Stable:
ICU 2.0

void DateFormatSymbols::setAmPmStrings const UnicodeString ampms,
int32_t  count
 

Sets ampm strings.

For example: "AM" and "PM".

Parameters:
ampms the new ampm strings. (not adopted; caller retains ownership)
count Filled in with length of the array.

Stable:
ICU 2.0

void DateFormatSymbols::setEraNames const UnicodeString eraNames,
int32_t  count
 

Sets era name strings.

For example: "Anno Domini" and "Before Christ".

Parameters:
eraNames Array of era name strings (DateFormatSymbols retains ownership.)
count Filled in with length of the array.

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

void DateFormatSymbols::setEras const UnicodeString eras,
int32_t  count
 

Sets era strings.

For example: "AD" and "BC".

Parameters:
eras Array of era strings (DateFormatSymbols retains ownership.)
count Filled in with length of the array.

Stable:
ICU 2.0

void DateFormatSymbols::setLocalPatternChars const UnicodeString newLocalPatternChars  ) 
 

Sets localized date-time pattern characters.

For example: 'u', 't', etc.

Parameters:
newLocalPatternChars the new localized date-time pattern characters.

Stable:
ICU 2.0

void DateFormatSymbols::setMonths const UnicodeString months,
int32_t  count,
DtContextType  context,
DtWidthType  width
 

Sets month strings by width and context.

For example: "January", "February", etc.

Parameters:
months The new month strings. (not adopted; caller retains ownership)
count Filled in with length of the array.
context The formatting context, either FORMAT or STANDALONE
width The width of returned strings, either WIDE, ABBREVIATED, or NARROW.

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

void DateFormatSymbols::setMonths const UnicodeString months,
int32_t  count
 

Sets month strings.

For example: "January", "February", etc.

Parameters:
months the new month strings. (not adopted; caller retains ownership)
count Filled in with length of the array.

Stable:
ICU 2.0

void DateFormatSymbols::setQuarters const UnicodeString quarters,
int32_t  count,
DtContextType  context,
DtWidthType  width
 

Sets quarter strings by width and context.

For example: "1st Quarter", "2nd Quarter", etc.

Parameters:
quarters The new quarter strings. (not adopted; caller retains ownership)
count Filled in with length of the array.
context The formatting context, either FORMAT or STANDALONE
width The width of returned strings, either WIDE or ABBREVIATED. There are no NARROW quarters.

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

void DateFormatSymbols::setShortMonths const UnicodeString shortMonths,
int32_t  count
 

Sets short month strings.

For example: "Jan", "Feb", etc.

Parameters:
count Filled in with length of the array.
shortMonths the new short month strings. (not adopted; caller retains ownership)

Stable:
ICU 2.0

void DateFormatSymbols::setShortWeekdays const UnicodeString shortWeekdays,
int32_t  count
 

Sets short weekday strings.

For example: "Sun", "Mon", etc.

Parameters:
shortWeekdays the new short weekday strings. (not adopted; caller retains ownership)
count Filled in with length of the array.

Stable:
ICU 2.0

void DateFormatSymbols::setWeekdays const UnicodeString weekdays,
int32_t  count,
DtContextType  context,
DtWidthType  width
 

Sets weekday strings by width and context.

For example: "Sunday", "Monday", etc.

Parameters:
weekdays The new weekday strings. (not adopted; caller retains ownership)
count Filled in with length of the array.
context The formatting context, either FORMAT or STANDALONE
width The width of returned strings, either WIDE, ABBREVIATED, or NARROW

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

void DateFormatSymbols::setWeekdays const UnicodeString weekdays,
int32_t  count
 

Sets weekday strings.

For example: "Sunday", "Monday", etc.

Parameters:
weekdays the new weekday strings. (not adopted; caller retains ownership)
count Filled in with length of the array.

Stable:
ICU 2.0

void DateFormatSymbols::setZoneString const UnicodeString ID,
const TimeZoneTranslationType  type,
const UnicodeString value,
UErrorCode status
 

Sets timezone string for the given the ID and translation type.

Parameters:
ID The ID of zone strings, e.g: "America/Los_Angeles". The time zone ID is for programmatic lookup.
type The translation type to set the value for
value The string with which current translation needs to be replaced
status Input/output parameter, set to success or

Internal:
Do not use. This API is for interal use only. ICU 3.6

void DateFormatSymbols::setZoneStrings const UnicodeString *const *  strings,
int32_t  rowCount,
int32_t  columnCount
 

Sets timezone strings.

These strings are stored in a 2-dimensional array.

Parameters:
strings The timezone strings as a 2-d array to be copied. (not adopted; caller retains ownership)
rowCount The number of rows (count of first index).
columnCount The number of columns (count of second index).

Stable:
ICU 2.0


The documentation for this class was generated from the following file:
Generated on Sun Jan 27 08:26:15 2008 for ICU 3.6 by  doxygen 1.3.9.1