* 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 TimeUnitAmount * @see TimeUnitFormat * @deprecated ICU 53 Use the MeasureFormat class instead. */ class U_I18N_API TimeUnitFormat: public MeasureFormat { public: /** * Create TimeUnitFormat with default locale, and full name style. * Use setLocale and/or setFormat to modify. * @deprecated ICU 53 */ TimeUnitFormat(UErrorCode& status); /** * Create TimeUnitFormat given locale, and full name style. * @deprecated ICU 53 */ TimeUnitFormat(const Locale& locale, UErrorCode& status); /** * Create TimeUnitFormat given locale and style. * @deprecated ICU 53 */ TimeUnitFormat(const Locale& locale, UTimeUnitFormatStyle style, UErrorCode& status); /** * Copy constructor. * @deprecated ICU 53 */ TimeUnitFormat(const TimeUnitFormat&); /** * deconstructor * @deprecated ICU 53 */ virtual ~TimeUnitFormat(); /** * Clone this Format object polymorphically. The caller owns the result and * should delete it when done. * @return A copy of the object. * @deprecated ICU 53 */ virtual TimeUnitFormat* clone() const; /** * Assignment operator * @deprecated ICU 53 */ TimeUnitFormat& operator=(const TimeUnitFormat& other); /** * Return true if the given Format objects are not semantically equal. * Objects of different subclasses are considered unequal. * @param other the object to be compared with. * @return true if the given Format objects are not semantically equal. * @deprecated ICU 53 */ UBool operator!=(const Format& other) const; /** * Set the locale used for formatting or parsing. * @param locale the locale to be set * @param status output param set to success/failure code on exit * @deprecated ICU 53 */ void setLocale(const Locale& locale, UErrorCode& status); /** * Set the number format used for formatting or parsing. * @param format the number formatter to be set * @param status output param set to success/failure code on exit * @deprecated ICU 53 */ void setNumberFormat(const NumberFormat& format, UErrorCode& status); /** * Parse a TimeUnitAmount. * @see Format#parseObject(const UnicodeString&, Formattable&, ParsePosition&) const; * @deprecated ICU 53 */ virtual void parseObject(const UnicodeString& source, Formattable& result, ParsePosition& pos) const; /** * Return the class ID for this class. This is useful only for comparing to * a return value from getDynamicClassID(). For example: *
* . Base* polymorphic_pointer = createPolymorphicObject(); * . if (polymorphic_pointer->getDynamicClassID() == * . erived::getStaticClassID()) ... *