Logo Search packages:      
Sourcecode: icu version File versions  Download package

TimeUnitFormat Class Reference

#include <tmutfmt.h>

Inheritance diagram for TimeUnitFormat:

MeasureFormat Format UObject UMemory

List of all members.

Detailed Description

Format or parse a TimeUnitAmount, using plural rules for the units where available.

Code Sample:

   // create time unit amount instance - a combination of Number and time unit
   UErrorCode status = U_ZERO_ERROR;
   TimeUnitAmount* source = new TimeUnitAmount(2, TimeUnit::UTIMEUNIT_YEAR, status);
   // create time unit format instance
   TimeUnitFormat* format = new TimeUnitFormat(Locale("en"), status);
   // format a time unit amount
   UnicodeString formatted;
   Formattable formattable;
   if (U_SUCCESS(status)) {
       formatted = ((Format*)format)->format(formattable, formatted, status);
       Formattable result;
       ((Format*)format)->parseObject(formatted, result, status);
       if (U_SUCCESS(status)) {
           assert (result == formattable);

See also:

TimeUnitFormat ICU 4.2

Definition at line 69 of file tmutfmt.h.

Public Types

enum  EStyle { kFull = 0, kAbbreviate = 1, kTotal = kAbbreviate + 1 }

Public Member Functions

virtual Formatclone (void) const
virtual UnicodeStringformat (const Formattable &obj, UnicodeString &appendTo, FieldPositionIterator *posIter, UErrorCode &status) const
UnicodeStringformat (const Formattable &obj, UnicodeString &appendTo, UErrorCode &status) const
virtual UnicodeStringformat (const Formattable &obj, UnicodeString &toAppendTo, FieldPosition &pos, UErrorCode &status) const
virtual UClassID getDynamicClassID (void) const
Locale getLocale (ULocDataLocaleType type, UErrorCode &status) const
const char * getLocaleID (ULocDataLocaleType type, UErrorCode &status) const
UBool operator!= (const Format &other) const
TimeUnitFormatoperator= (const TimeUnitFormat &other)
virtual UBool operator== (const Format &other) const
void parseObject (const UnicodeString &source, Formattable &result, UErrorCode &status) const
virtual void parseObject (const UnicodeString &source, Formattable &result, ParsePosition &pos) const
void setLocale (const Locale &locale, UErrorCode &status)
void setNumberFormat (const NumberFormat &format, UErrorCode &status)
 TimeUnitFormat (const TimeUnitFormat &)
 TimeUnitFormat (const Locale &locale, EStyle style, UErrorCode &status)
 TimeUnitFormat (const Locale &locale, UErrorCode &status)
 TimeUnitFormat (UErrorCode &status)
virtual ~TimeUnitFormat ()

Static Public Member Functions

static MeasureFormat *U_EXPORT2 createCurrencyFormat (UErrorCode &ec)
static MeasureFormat *U_EXPORT2 createCurrencyFormat (const Locale &locale, UErrorCode &ec)
static UClassID U_EXPORT2 getStaticClassID (void)
static void U_EXPORT2 operator delete (void *, void *) U_NO_THROW
static void U_EXPORT2 operator delete (void *p) U_NO_THROW
static void U_EXPORT2 operator delete[] (void *p) U_NO_THROW
static void *U_EXPORT2 operator new (size_t, void *ptr) U_NO_THROW
static void *U_EXPORT2 operator new (size_t size) U_NO_THROW
static void *U_EXPORT2 operator new[] (size_t size) U_NO_THROW

Protected Member Functions

void setLocaleIDs (const char *valid, const char *actual)

Static Protected Member Functions

static void syntaxError (const UnicodeString &pattern, int32_t pos, UParseError &parseError)

Private Member Functions

void checkConsistency (EStyle style, const char *key, UErrorCode &status)
void copyHash (const Hashtable *source, Hashtable *target, UErrorCode &status)
void create (const Locale &locale, EStyle style, UErrorCode &status)
void deleteHash (Hashtable *htable)
void initDataMembers (UErrorCode &status)
HashtableinitHash (UErrorCode &status)
void readFromCurrentLocale (EStyle style, const char *key, UErrorCode &status)
void searchInLocaleChain (EStyle style, const char *key, TimeUnit::UTimeUnitFields field, const char *, const char *, Hashtable *, UErrorCode &)
void setup (UErrorCode &status)

Static Private Member Functions

static const char * getTimeUnitName (TimeUnit::UTimeUnitFields field, UErrorCode &status)

Private Attributes

Locale fLocale
EStyle fStyle
HashtablefTimeUnitToCountToPatterns [TimeUnit::UTIMEUNIT_FIELD_COUNT]

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

Generated by  Doxygen 1.6.0   Back to index