Showing content from https://unicode-org.github.io/icu-docs/apidoc/released/icu4c/classicu_1_1TimeUnitFormat.html below:
ICU 77.1: icu::TimeUnitFormat Class Reference
TimeUnitFormat (UErrorCode &status) Create TimeUnitFormat with default locale, and full name style. More...
TimeUnitFormat (const Locale &locale, UErrorCode &status) Create TimeUnitFormat given locale, and full name style. More...
TimeUnitFormat (const Locale &locale, UTimeUnitFormatStyle style, UErrorCode &status) Create TimeUnitFormat given locale and style. More...
TimeUnitFormat (const TimeUnitFormat &) Copy constructor. More...
virtual ~TimeUnitFormat () deconstructor More...
virtual TimeUnitFormat * clone () const override Clone this Format object polymorphically. More...
TimeUnitFormat & operator= (const TimeUnitFormat &other) Assignment operator. More...
void setLocale (const Locale &locale, UErrorCode &status) Set the locale used for formatting or parsing. More...
void setNumberFormat (const NumberFormat &format, UErrorCode &status) Set the number format used for formatting or parsing. More...
virtual void parseObject (const UnicodeString &source, Formattable &result, ParsePosition &pos) const override Parse a TimeUnitAmount. More...
virtual UClassID getDynamicClassID () const override Returns a unique class ID POLYMORPHICALLY. More...
MeasureFormat (const Locale &locale, UMeasureFormatWidth width, UErrorCode &status) Constructor. More...
MeasureFormat (const Locale &locale, UMeasureFormatWidth width, NumberFormat *nfToAdopt, UErrorCode &status) Constructor. More...
MeasureFormat (const MeasureFormat &other) Copy constructor. More...
MeasureFormat & operator= (const MeasureFormat &rhs) Assignment operator. More...
virtual ~MeasureFormat () Destructor. More...
virtual bool operator== (const Format &other) const override Return true if given Format objects are semantically equal. More...
virtual UnicodeString & format (const Formattable &obj, UnicodeString &appendTo, FieldPosition &pos, UErrorCode &status) const override Formats object to produce a string. More...
UnicodeString & formatMeasures (const Measure *measures, int32_t measureCount, UnicodeString &appendTo, FieldPosition &pos, UErrorCode &status) const Formats measure objects to produce a string. More...
UnicodeString & formatMeasurePerUnit (const Measure &measure, const MeasureUnit &perUnit, UnicodeString &appendTo, FieldPosition &pos, UErrorCode &status) const Formats a single measure per unit. More...
UnicodeString getUnitDisplayName (const MeasureUnit &unit, UErrorCode &status) const Gets the display name of the specified MeasureUnit corresponding to the current locale and format width. More...
virtual void parseObject (const UnicodeString &source, Formattable &result, ParsePosition &parse_pos) const=0 Parse a string to produce an object. More...
void parseObject (const UnicodeString &source, Formattable &result, UErrorCode &status) const Parses a string to produce an object. More...
UnicodeString & format (const Formattable &obj, UnicodeString &appendTo, UErrorCode &status) const Formats an object to produce a string. More...
virtual UnicodeString & format (const Formattable &obj, UnicodeString &appendTo, FieldPosition &pos, UErrorCode &status) const=0 Format an object to produce a string. More...
virtual UnicodeString & format (const Formattable &obj, UnicodeString &appendTo, FieldPositionIterator *posIter, UErrorCode &status) const Format an object to produce a string. More...
virtual ~Format () Destructor. More...
bool operator!= (const Format &other) const Return true if the given Format objects are not semantically equal. More...
UnicodeString & format (const Formattable &obj, UnicodeString &appendTo, UErrorCode &status) const Formats an object to produce a string. More...
virtual UnicodeString & format (const Formattable &obj, UnicodeString &appendTo, FieldPositionIterator *posIter, UErrorCode &status) const Format an object to produce a string. More...
void parseObject (const UnicodeString &source, Formattable &result, UErrorCode &status) const Parses a string to produce an object. More...
Locale getLocale (ULocDataLocaleType type, UErrorCode &status) const Get the locale for this format object. More...
const char * getLocaleID (ULocDataLocaleType type, UErrorCode &status) const Get the locale for this format object. More...
virtual ~UObject () Destructor. More...
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)) {
formattable.adoptObject(source);
formatted = ((Format*)format)->format(formattable, formatted, status);
Formattable result;
((Format*)format)->parseObject(formatted, result, status);
if (U_SUCCESS(status)) {
assert (result == formattable);
}
}
-
See also
-
TimeUnitAmount
-
TimeUnitFormat
-
Deprecated:
-
ICU 53 Use the MeasureFormat class instead.
Definition at line 89 of file tmutfmt.h.
RetroSearch is an open source project built by @garambo
| Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4