# TimeUnitAmount Class Reference

Express a duration as a time unit and number. More...

`#include <tmutamt.h>`

Inheritance diagram for TimeUnitAmount:

## Public Member Functions
| TimeUnitAmount (const Formattable &number, TimeUnit::UTimeUnitFields timeUnitField, UErrorCode &status)
| Construct TimeUnitAmount object with the given number and the given time unit.
| TimeUnitAmount (double amount, TimeUnit::UTimeUnitFields timeUnitField, UErrorCode &status)
| Construct TimeUnitAmount object with the given numeric amount and the given time unit.
| TimeUnitAmount (const TimeUnitAmount &other)
| Copy constructor.
TimeUnitAmount & | operator= (const TimeUnitAmount &other)
| Assignment operator.
virtual UObject * | clone () const
| Clone.
virtual | ~TimeUnitAmount ()
| Destructor.
virtual UBool | operator== (const UObject &other) const
| Equality operator.
UBool | operator!= (const UObject &other) const
| Not-equality operator.
virtual UClassID | getDynamicClassID (void) const
| Returns a unique class ID POLYMORPHICALLY.
const TimeUnit & | getTimeUnit () const
| Get the time unit.
TimeUnit::UTimeUnitFields | getTimeUnitField () const
| Get the time unit field value.
## Static Public Member Functions
static UClassID | getStaticClassID (void)
| Return the class ID for this class.

## Detailed Description

Express a duration as a time unit and number.

Patterned after Currency.

See also:
  TimeUnitAmount

  TimeUnitFormat

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

Definition at line 31 of file tmutamt.h.

## Constructor & Destructor Documentation

TimeUnitAmount::TimeUnitAmount | ( | const Formattable & | number,
|  | TimeUnit::UTimeUnitFields | timeUnitField,
|  | UErrorCode & | status |
| ) |  |  |

Construct TimeUnitAmount object with the given number and the given time unit.

Parameters:

  | number | a numeric object; number.isNumeric() must be TRUE
  | timeUnitField | the time unit field of a time unit
  | status | the input-output error code. If the number is not numeric or the timeUnitField is not valid, then this will be set to a failing value: U_ILLEGAL_ARGUMENT_ERROR.

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

TimeUnitAmount::TimeUnitAmount | ( | double | amount,
|  | TimeUnit::UTimeUnitFields | timeUnitField,
|  | UErrorCode & | status |
| ) |  |  |

Construct TimeUnitAmount object with the given numeric amount and the given time unit.

Parameters:

  | amount | a numeric amount.
  | timeUnitField | the time unit field on which a time unit amount object will be created.
  | status | the input-output error code. If the timeUnitField is not valid, then this will be set to a failing value: U_ILLEGAL_ARGUMENT_ERROR.

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

TimeUnitAmount::TimeUnitAmount | ( | const TimeUnitAmount & | other | ) |

Copy constructor.

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

virtual TimeUnitAmount::~TimeUnitAmount | ( |  | ) | `[virtual]`

Destructor.

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

## Member Function Documentation

virtual UObject* TimeUnitAmount::clone | ( |  | ) | const`[virtual]`

Clone.

Returns:
  a polymorphic clone of this object. The result will have the same class as returned by getDynamicClassID().

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

Implements Measure.

virtual UClassID TimeUnitAmount::getDynamicClassID | ( | void |  | ) | const`[virtual]`

Returns a unique class ID POLYMORPHICALLY.

Pure virtual override. This method is to implement a simple version of RTTI, since not all C++ compilers support genuine RTTI. Polymorphic operator==() and clone() methods call this method.

Returns:
  The class ID for this object. All objects of a given class have the same class ID. Objects of other classes have different class IDs.

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

Implements UObject.

static UClassID TimeUnitAmount::getStaticClassID | ( | void |  | ) | `[static]`

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()) ...

Returns:
  The class ID for all objects of this class.

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

const TimeUnit& TimeUnitAmount::getTimeUnit | ( |  | ) | const

Get the time unit.

Returns:
  time unit object.

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

TimeUnit::UTimeUnitFields TimeUnitAmount::getTimeUnitField | ( |  | ) | const

Get the time unit field value.

Returns:
  time unit field value.

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

UBool TimeUnitAmount::operator!= | ( | const UObject & | other | ) | const`[inline]`

Not-equality operator.

Parameters:

  | other | the object to compare to.

Returns:
  true if this object is not equal to the given object.

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

Definition at line 158 of file tmutamt.h.

References operator==().

TimeUnitAmount& TimeUnitAmount::operator= | ( | const TimeUnitAmount & | other | ) |

Assignment operator.

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

virtual UBool TimeUnitAmount::operator== | ( | const UObject & | other | ) | const`[virtual]`

Equality operator.

Parameters:

  | other | the object to compare to.

Returns:
  true if this object is equal to the given object.

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

Reimplemented from Measure.

Referenced by operator!=().

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

- tmutamt.h