Added in API level 24

TimeUnit


open class TimeUnit : MeasureUnit

Measurement unit for time units.

Summary

Public methods
open static Array<TimeUnit!>!

Inherited functions
Boolean equals(other: Any?)

Indicates whether some other object is "equal to" this one.

The equals method implements an equivalence relation on non-null object references:

  • It is reflexive: for any non-null reference value x, x.equals(x) should return true.
  • It is symmetric: for any non-null reference values x and y, x.equals(y) should return true if and only if y.equals(x) returns true.
  • It is transitive: for any non-null reference values x, y, and z, if x.equals(y) returns true and y.equals(z) returns true, then x.equals(z) should return true.
  • It is consistent: for any non-null reference values x and y, multiple invocations of x.equals(y) consistently return true or consistently return false, provided no information used in equals comparisons on the objects is modified.
  • For any non-null reference value x, x.equals(null) should return false.

An equivalence relation partitions the elements it operates on into equivalence classes; all the members of an equivalence class are equal to each other. Members of an equivalence class are substitutable for each other, at least for some purposes.

MeasureUnit! forIdentifier(identifier: String!)

Construct a MeasureUnit from a CLDR Core Unit Identifier, defined in UTS 35. (Core unit identifiers and mixed unit identifiers are supported, long unit identifiers are not.) Validates and canonicalizes the identifier. Note: dimensionless MeasureUnit is null

MeasureUnit example = MeasureUnit::forIdentifier("furlong-per-nanosecond")
  

MutableSet<MeasureUnit!>! getAvailable()

Get all of the available units. Returned set is unmodifiable.

MutableSet<MeasureUnit!>! getAvailable(type: String!)

For the given type, return the available units.

MutableSet<String!>! getAvailableTypes()

Get all of the available units' types. Returned set is unmodifiable.

MeasureUnit.Complexity! getComplexity()

Compute the complexity of the unit. See Complexity for more information.

Int getDimensionality()

Returns the dimensionality (power) of this MeasureUnit. For example, if the unit is square, then 2 is returned.

NOTE: Only works on SINGLE units. If this is a COMPOUND or MIXED unit, an exception will be thrown. For more information, Complexity.

String! getIdentifier()

Get CLDR Unit Identifier for this MeasureUnit, as defined in UTS 35.

MeasureUnit.MeasurePrefix! getPrefix()

Returns the current SI or binary prefix of this SINGLE unit. For example, if the unit has the prefix "kilo", then MeasurePrefix.KILO is returned.

NOTE: Only works on SINGLE units. If this is a COMPOUND or MIXED unit, an error will occur. For more information, Complexity.

String! getSubtype()

Get the subType, such as “foot”. May return null.

String! getType()

Get the type, such as "length". May return null.

Int hashCode()

Returns a hash code value for the object. This method is supported for the benefit of hash tables such as those provided by java.util.HashMap.

The general contract of hashCode is:

  • Whenever it is invoked on the same object more than once during an execution of a Java application, the hashCode method must consistently return the same integer, provided no information used in equals comparisons on the object is modified. This integer need not remain consistent from one execution of an application to another execution of the same application.
  • If two objects are equal according to the equals method, then calling the hashCode method on each of the two objects must produce the same integer result.
  • It is not required that if two objects are unequal according to the equals method, then calling the hashCode method on each of the two objects must produce distinct integer results. However, the programmer should be aware that producing distinct integer results for unequal objects may improve the performance of hash tables.

MeasureUnit! product(other: MeasureUnit!)

Computes the product of this unit with another unit. This is a way to build units from constituent parts.

The numerator and denominator are preserved through this operation.

For example, if the receiver is "kilowatt" and the argument is "hour-per-day", then the unit "kilowatt-hour-per-day" is returned.

NOTE: Only works on SINGLE and COMPOUND units. If either unit (receivee and argument) is a MIXED unit, an error will occur. For more information, Complexity.

MeasureUnit! reciprocal()

Computes the reciprocal of this MeasureUnit, with the numerator and denominator flipped.

For example, if the receiver is "meter-per-second", the unit "second-per-meter" is returned.

NOTE: Only works on SINGLE and COMPOUND units. If this is a MIXED unit, an error will occur. For more information, Complexity.

MutableList<MeasureUnit!>! splitToSingleUnits()

Returns the list of SINGLE units contained within a sequence of COMPOUND units.

Examples: - Given "meter-kilogram-per-second", three units will be returned: "meter", "kilogram", and "per-second". - Given "hour+minute+second", three units will be returned: "hour", "minute", and "second".

If this is a SINGLE unit, a list of length 1 will be returned.

String toString()

Returns a string representation of the object.

MeasureUnit! withDimensionality(dimensionality: Int)

Creates a MeasureUnit which is this SINGLE unit augmented with the specified dimensionality (power). For example, if dimensionality is 2, the unit will be squared.

NOTE: Only works on SINGLE units. If this is a COMPOUND or MIXED unit, an exception is thrown. For more information, Complexity.

MeasureUnit! withPrefix(prefix: MeasureUnit.MeasurePrefix!)

Creates a MeasureUnit which is this SINGLE unit augmented with the specified prefix. For example, MeasurePrefix.KILO for "kilo", or MeasurePrefix.KIBI for "kibi". May return this if this unit already has that prefix.

There is sufficient locale data to format all standard prefixes.

NOTE: Only works on SINGLE units. If this is a COMPOUND or MIXED unit, an error will occur. For more information, Complexity.

Inherited properties
MeasureUnit! ACRE

Constant for unit of area: acre

MeasureUnit! ACRE_FOOT

Constant for unit of volume: acre-foot

MeasureUnit! AMPERE

Constant for unit of electric: ampere

MeasureUnit! ARC_MINUTE

Constant for unit of angle: arc-minute

MeasureUnit! ARC_SECOND

Constant for unit of angle: arc-second

MeasureUnit! ASTRONOMICAL_UNIT

Constant for unit of length: astronomical-unit

MeasureUnit! ATMOSPHERE

Constant for unit of pressure: atmosphere

MeasureUnit! BEAUFORT

Constant for unit of speed: beaufort

MeasureUnit! BIT

Constant for unit of digital: bit

MeasureUnit! BUSHEL

Constant for unit of volume: bushel

MeasureUnit! BYTE

Constant for unit of digital: byte

MeasureUnit! CALORIE

Constant for unit of energy: calorie

MeasureUnit! CANDELA

Constant for unit of light: candela

MeasureUnit! CARAT

Constant for unit of mass: carat

MeasureUnit! CELSIUS

Constant for unit of temperature: celsius

MeasureUnit! CENTILITER

Constant for unit of volume: centiliter

MeasureUnit! CENTIMETER

Constant for unit of length: centimeter

MeasureUnit! CENTURY

Constant for unit of duration: century

MeasureUnit! CUBIC_CENTIMETER

Constant for unit of volume: cubic-centimeter

MeasureUnit! CUBIC_FOOT

Constant for unit of volume: cubic-foot

MeasureUnit! CUBIC_INCH

Constant for unit of volume: cubic-inch

MeasureUnit! CUBIC_KILOMETER

Constant for unit of volume: cubic-kilometer

MeasureUnit! CUBIC_METER

Constant for unit of volume: cubic-meter

MeasureUnit! CUBIC_MILE

Constant for unit of volume: cubic-mile

MeasureUnit! CUBIC_YARD

Constant for unit of volume: cubic-yard

MeasureUnit! CUP

Constant for unit of volume: cup

MeasureUnit! CUP_METRIC

Constant for unit of volume: cup-metric

TimeUnit! DAY

Constant for unit of duration: day

MeasureUnit! DECADE

Constant for unit of duration: decade

MeasureUnit! DECILITER

Constant for unit of volume: deciliter

MeasureUnit! DECIMETER

Constant for unit of length: decimeter

MeasureUnit! DEGREE

Constant for unit of angle: degree

MeasureUnit! DOT

Constant for unit of graphics: dot

MeasureUnit! DOT_PER_CENTIMETER

Constant for unit of graphics: dot-per-centimeter

MeasureUnit! DOT_PER_INCH

Constant for unit of graphics: dot-per-inch

MeasureUnit! EM

Constant for unit of graphics: em

MeasureUnit! FAHRENHEIT

Constant for unit of temperature: fahrenheit

MeasureUnit! FATHOM

Constant for unit of length: fathom

MeasureUnit! FLUID_OUNCE

Constant for unit of volume: fluid-ounce

MeasureUnit! FOODCALORIE

Constant for unit of energy: foodcalorie

MeasureUnit! FOOT

Constant for unit of length: foot

MeasureUnit! FURLONG

Constant for unit of length: furlong

MeasureUnit! GALLON

Constant for unit of volume: gallon

MeasureUnit! GALLON_IMPERIAL

Constant for unit of volume: gallon-imperial

MeasureUnit! GASOLINE_ENERGY_DENSITY

Constant for unit of pressure: gasoline-energy-density

MeasureUnit! GENERIC_TEMPERATURE

Constant for unit of temperature: generic

MeasureUnit! GIGABIT

Constant for unit of digital: gigabit

MeasureUnit! GIGABYTE

Constant for unit of digital: gigabyte

MeasureUnit! GIGAHERTZ

Constant for unit of frequency: gigahertz

MeasureUnit! GIGAWATT

Constant for unit of power: gigawatt

MeasureUnit! GRAM

Constant for unit of mass: gram

MeasureUnit! G_FORCE

Constant for unit of acceleration: g-force

MeasureUnit! HECTARE

Constant for unit of area: hectare

MeasureUnit! HECTOLITER

Constant for unit of volume: hectoliter

MeasureUnit! HECTOPASCAL

Constant for unit of pressure: hectopascal

MeasureUnit! HERTZ

Constant for unit of frequency: hertz

MeasureUnit! HORSEPOWER

Constant for unit of power: horsepower

TimeUnit! HOUR

Constant for unit of duration: hour

MeasureUnit! INCH

Constant for unit of length: inch

MeasureUnit! INCH_HG

Constant for unit of pressure: inch-ofhg

MeasureUnit! ITEM

Constant for unit of concentr: item

MeasureUnit! JOULE

Constant for unit of energy: joule

MeasureUnit! KARAT

Constant for unit of concentr: karat

MeasureUnit! KELVIN

Constant for unit of temperature: kelvin

MeasureUnit! KILOBIT

Constant for unit of digital: kilobit

MeasureUnit! KILOBYTE

Constant for unit of digital: kilobyte

MeasureUnit! KILOCALORIE

Constant for unit of energy: kilocalorie

MeasureUnit! KILOGRAM

Constant for unit of mass: kilogram

MeasureUnit! KILOHERTZ

Constant for unit of frequency: kilohertz

MeasureUnit! KILOJOULE

Constant for unit of energy: kilojoule

MeasureUnit! KILOMETER

Constant for unit of length: kilometer

MeasureUnit! KILOMETER_PER_HOUR

Constant for unit of speed: kilometer-per-hour

MeasureUnit! KILOWATT

Constant for unit of power: kilowatt

MeasureUnit! KILOWATT_HOUR

Constant for unit of energy: kilowatt-hour

MeasureUnit! KILOWATT_HOUR_PER_100_KILOMETER

Constant for unit of force: kilowatt-hour-per-100-kilometer

MeasureUnit! KNOT

Constant for unit of speed: knot

MeasureUnit! LIGHT_YEAR

Constant for unit of length: light-year

MeasureUnit! LITER

Constant for unit of volume: liter

MeasureUnit! LITER_PER_100KILOMETERS

Constant for unit of consumption: liter-per-100-kilometer

MeasureUnit! LITER_PER_KILOMETER

Constant for unit of consumption: liter-per-kilometer

MeasureUnit! LUMEN

Constant for unit of light: lumen

MeasureUnit! LUX

Constant for unit of light: lux

MeasureUnit! MEGABIT

Constant for unit of digital: megabit

MeasureUnit! MEGABYTE

Constant for unit of digital: megabyte

MeasureUnit! MEGAHERTZ

Constant for unit of frequency: megahertz

MeasureUnit! MEGALITER

Constant for unit of volume: megaliter

MeasureUnit! MEGAPIXEL

Constant for unit of graphics: megapixel

MeasureUnit! MEGAWATT

Constant for unit of power: megawatt

MeasureUnit! METER

Constant for unit of length: meter

MeasureUnit! METER_PER_SECOND

Constant for unit of speed: meter-per-second

MeasureUnit! METER_PER_SECOND_SQUARED

Constant for unit of acceleration: meter-per-square-second

MeasureUnit! METRIC_TON

Constant for unit of mass: metric-ton (renamed to tonne in CLDR 42 / ICU 72). Note: In ICU 74 this will be deprecated in favor of TONNE, which is currently draft but will become stable in ICU 74, and which uses the preferred naming.

MeasureUnit! MICROGRAM

Constant for unit of mass: microgram

MeasureUnit! MICROMETER

Constant for unit of length: micrometer

MeasureUnit! MICROSECOND

Constant for unit of duration: microsecond

MeasureUnit! MILE

Constant for unit of length: mile

MeasureUnit! MILE_PER_GALLON

Constant for unit of consumption: mile-per-gallon

MeasureUnit! MILE_PER_GALLON_IMPERIAL

Constant for unit of consumption: mile-per-gallon-imperial

MeasureUnit! MILE_PER_HOUR

Constant for unit of speed: mile-per-hour

MeasureUnit! MILE_SCANDINAVIAN

Constant for unit of length: mile-scandinavian

MeasureUnit! MILLIAMPERE

Constant for unit of electric: milliampere

MeasureUnit! MILLIBAR

Constant for unit of pressure: millibar

MeasureUnit! MILLIGRAM

Constant for unit of mass: milligram

MeasureUnit! MILLIGRAM_OFGLUCOSE_PER_DECILITER

Constant for unit of concentr: milligram-ofglucose-per-deciliter

MeasureUnit! MILLIGRAM_PER_DECILITER

Constant for unit of concentr: milligram-per-deciliter

MeasureUnit! MILLILITER

Constant for unit of volume: milliliter

MeasureUnit! MILLIMETER

Constant for unit of length: millimeter

MeasureUnit! MILLIMETER_OF_MERCURY

Constant for unit of pressure: millimeter-ofhg

MeasureUnit! MILLIMOLE_PER_LITER

Constant for unit of concentr: millimole-per-liter

MeasureUnit! MILLISECOND

Constant for unit of duration: millisecond

MeasureUnit! MILLIWATT

Constant for unit of power: milliwatt

TimeUnit! MINUTE

Constant for unit of duration: minute

TimeUnit! MONTH

Constant for unit of duration: month

MeasureUnit! NANOMETER

Constant for unit of length: nanometer

MeasureUnit! NANOSECOND

Constant for unit of duration: nanosecond

MeasureUnit! NAUTICAL_MILE

Constant for unit of length: nautical-mile

MeasureUnit! OHM

Constant for unit of electric: ohm

MeasureUnit! OUNCE

Constant for unit of mass: ounce

MeasureUnit! OUNCE_TROY

Constant for unit of mass: ounce-troy

MeasureUnit! PARSEC

Constant for unit of length: parsec

MeasureUnit! PART_PER_MILLION

Constant for unit of concentr: permillion

MeasureUnit! PERCENT

Constant for unit of concentr: percent

MeasureUnit! PERMILLE

Constant for unit of concentr: permille

MeasureUnit! PETABYTE

Constant for unit of digital: petabyte

MeasureUnit! PICOMETER

Constant for unit of length: picometer

MeasureUnit! PINT

Constant for unit of volume: pint

MeasureUnit! PINT_METRIC

Constant for unit of volume: pint-metric

MeasureUnit! PIXEL

Constant for unit of graphics: pixel

MeasureUnit! PIXEL_PER_CENTIMETER

Constant for unit of graphics: pixel-per-centimeter

MeasureUnit! PIXEL_PER_INCH

Constant for unit of graphics: pixel-per-inch

MeasureUnit! POINT

Constant for unit of length: point

MeasureUnit! POUND

Constant for unit of mass: pound

MeasureUnit! POUND_PER_SQUARE_INCH

Constant for unit of pressure: pound-force-per-square-inch

MeasureUnit! QUART

Constant for unit of volume: quart

MeasureUnit! QUARTER

Constant for unit of duration: quarter

MeasureUnit! RADIAN

Constant for unit of angle: radian

MeasureUnit! REVOLUTION_ANGLE

Constant for unit of angle: revolution

TimeUnit! SECOND

Constant for unit of duration: second

MeasureUnit! SQUARE_CENTIMETER

Constant for unit of area: square-centimeter

MeasureUnit! SQUARE_FOOT

Constant for unit of area: square-foot

MeasureUnit! SQUARE_INCH

Constant for unit of area: square-inch

MeasureUnit! SQUARE_KILOMETER

Constant for unit of area: square-kilometer

MeasureUnit! SQUARE_METER

Constant for unit of area: square-meter

MeasureUnit! SQUARE_MILE

Constant for unit of area: square-mile

MeasureUnit! SQUARE_YARD

Constant for unit of area: square-yard

MeasureUnit! STONE

Constant for unit of mass: stone

MeasureUnit! TABLESPOON

Constant for unit of volume: tablespoon

MeasureUnit! TEASPOON

Constant for unit of volume: teaspoon

MeasureUnit! TERABIT

Constant for unit of digital: terabit

MeasureUnit! TERABYTE

Constant for unit of digital: terabyte

MeasureUnit! TON

Constant for unit of mass: ton

MeasureUnit! TONNE

Constant for unit of mass: tonne

MeasureUnit! VOLT

Constant for unit of electric: volt

MeasureUnit! WATT

Constant for unit of power: watt

TimeUnit! WEEK

Constant for unit of duration: week

MeasureUnit! YARD

Constant for unit of length: yard

TimeUnit! YEAR

Constant for unit of duration: year

Public methods

values

Added in API level 24
open static fun values(): Array<TimeUnit!>!
Return
Array<TimeUnit!>! the available values