Added in API level 24

Currency


open class Currency : MeasureUnit

A class encapsulating a currency, as defined by ISO 4217. A Currency object can be created given a Locale or given an ISO 4217 code. Once created, the Currency object can return various data necessary to its proper display:

  • A display symbol, for a specific locale
  • The number of fraction digits to display
  • A rounding increment
The DecimalFormat class uses these data to display currencies.

Note: This class deliberately resembles java.util.Currency but it has a completely independent implementation, and adds features not present in the JDK.

Summary

Nested classes

Currency Usage used for Decimal Format

Constants
static Int

Selector for getName() indicating the formal currency symbol.

static Int

Selector for getName() indicating the long name for a currency, such as "US Dollar" for USD.

static Int

Selector for getName() indicating the narrow currency symbol.

static Int

Selector for getName() indicating the plural long name for a currency, such as "US dollar" for USD in "1 US dollar", and "US dollars" for USD in "2 US dollars".

static Int

Selector for getName() indicating a symbolic name for a currency, such as "$" for USD.

static Int

Selector for getName() indicating the variant currency symbol.

Protected constructors
Currency(theISOCode: String!)

Constructs a currency object for the given ISO 4217 3-letter code.

Public methods
open static Currency!

Returns a Currency object based on the currency represented by the given java.

open static MutableSet<Currency!>!

Returns the set of available currencies.

open static Array<String!>!

Returns an array of Strings which contain the currency identifiers that are valid for the given locale on the given date.

open static Array<String!>!

Returns an array of Strings which contain the currency identifiers that are valid for the given java.util.Locale on the given date.

open static Array<Locale!>!

Return an array of the locales for which a currency is defined.

open static Array<ULocale!>!

Return an array of the ulocales for which a currency is defined.

open String!

Returns the ISO 4217 3-letter code for this currency object.

open Int

Returns the number of the number of fraction digits that should be displayed for this currency.

open Int

Returns the number of the number of fraction digits that should be displayed for this currency with Usage.

open String!

Returns the display name for this currency in the default locale.

open String!

Returns the display name for this currency in the given locale.

open static Currency!
getInstance(locale: ULocale!)

Returns a currency object for the default currency in the given locale.

open static Currency!
getInstance(theISOCode: String!)

Returns a currency object given an ISO 4217 3-letter code.

open static Currency!
getInstance(locale: Locale!)

Returns a currency object for the default currency in the given locale.

static Array<String!>!
getKeywordValuesForLocale(key: String!, locale: ULocale!, commonlyUsed: Boolean)

Given a key and a locale, returns an array of values for the key for which data exists.

open String!
getName(locale: ULocale!, nameStyle: Int, isChoiceFormat: BooleanArray!)

Returns the display name for the given currency in the given locale.

open String!
getName(locale: ULocale!, nameStyle: Int, pluralCount: String!, isChoiceFormat: BooleanArray!)

Returns the display name for the given currency in the given locale.

open String!
getName(locale: Locale!, nameStyle: Int, isChoiceFormat: BooleanArray!)

Returns the display name for the given currency in the given locale.

open String!
getName(locale: Locale!, nameStyle: Int, pluralCount: String!, isChoiceFormat: BooleanArray!)

Returns the display name for the given currency in the given locale.

open Int

Returns the ISO 4217 numeric code for this currency object.

open Double

Returns the rounding increment for this currency, or 0.

open Double

Returns the rounding increment for this currency, or 0.

open String!

Convenience and compatibility override of getName that requests the symbol name for the default DISPLAY locale.

open String!

Convenience and compatibility override of getName that requests the symbol name.

open String!

Convenience and compatibility override of getName that requests the symbol name.

open static Boolean
isAvailable(code: String!, from: Date!, to: Date!)

Queries if the given ISO 4217 3-letter code is available on the specified date range.

open Currency!

Returns a java.

open String

Returns the ISO 4217 code for this currency.

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.

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

Constants

FORMAL_SYMBOL_NAME

Added in API level 33
static val FORMAL_SYMBOL_NAME: Int

Selector for getName() indicating the formal currency symbol.

The formal currency symbol is similar to the regular currency symbol, but it always takes the form used in formal settings such as banking; for example, "NT$" instead of "$" for TWD in zh-TW.

Value: 4

LONG_NAME

Added in API level 24
static val LONG_NAME: Int

Selector for getName() indicating the long name for a currency, such as "US Dollar" for USD.

Value: 1

NARROW_SYMBOL_NAME

Added in API level 30
static val NARROW_SYMBOL_NAME: Int

Selector for getName() indicating the narrow currency symbol.

The narrow currency symbol is similar to the regular currency symbol, but it always takes the shortest form; for example, "$" instead of "US$" for USD in en-CA.

Value: 3

PLURAL_LONG_NAME

Added in API level 24
static val PLURAL_LONG_NAME: Int

Selector for getName() indicating the plural long name for a currency, such as "US dollar" for USD in "1 US dollar", and "US dollars" for USD in "2 US dollars".

Value: 2

SYMBOL_NAME

Added in API level 24
static val SYMBOL_NAME: Int

Selector for getName() indicating a symbolic name for a currency, such as "$" for USD.

Value: 0

VARIANT_SYMBOL_NAME

Added in API level 33
static val VARIANT_SYMBOL_NAME: Int

Selector for getName() indicating the variant currency symbol.

The variant symbol for a currency is an alternative symbol that is not necessarily as widely used as the regular symbol.

Value: 5

Protected constructors

Currency

Added in API level 24
protected Currency(theISOCode: String!)

Constructs a currency object for the given ISO 4217 3-letter code. This constructor assumes that the code is valid.

Parameters
theISOCode String!: The iso code used to construct the currency.

Public methods

fromJavaCurrency

Added in API level 29
open static fun fromJavaCurrency(currency: Currency!): Currency!

Returns a Currency object based on the currency represented by the given java.util.Currency.

Parameters
currency Currency!: The Java currency object to convert.
Return
Currency! An equivalent ICU currency object.

getAvailableCurrencies

Added in API level 24
open static fun getAvailableCurrencies(): MutableSet<Currency!>!

Returns the set of available currencies. The returned set of currencies contains all of the available currencies, including obsolete ones. The result set can be modified without affecting the available currencies in the runtime.

Return
MutableSet<Currency!>! The set of available currencies. The returned set could be empty if there is no currency data available.

getAvailableCurrencyCodes

Added in API level 24
open static fun getAvailableCurrencyCodes(
    loc: ULocale!,
    d: Date!
): Array<String!>!

Returns an array of Strings which contain the currency identifiers that are valid for the given locale on the given date. If there are no such identifiers, returns null. Returned identifiers are in preference order.

Parameters
loc ULocale!: the locale for which to retrieve currency codes.
d Date!: the date for which to retrieve currency codes for the given locale.
Return
Array<String!>! The array of ISO currency codes.

getAvailableCurrencyCodes

Added in API level 24
open static fun getAvailableCurrencyCodes(
    loc: Locale!,
    d: Date!
): Array<String!>!

Returns an array of Strings which contain the currency identifiers that are valid for the given java.util.Locale on the given date. If there are no such identifiers, returns null. Returned identifiers are in preference order.

Parameters
loc Locale!: the java.util.Locale for which to retrieve currency codes.
d Date!: the date for which to retrieve currency codes for the given locale.
Return
Array<String!>! The array of ISO currency codes.

getAvailableLocales

Added in API level 24
open static fun getAvailableLocales(): Array<Locale!>!

Return an array of the locales for which a currency is defined.

Return
Array<Locale!>! an array of the available locales

getAvailableULocales

Added in API level 24
open static fun getAvailableULocales(): Array<ULocale!>!

Return an array of the ulocales for which a currency is defined.

Return
Array<ULocale!>! an array of the available ulocales

getCurrencyCode

Added in API level 24
open fun getCurrencyCode(): String!

Returns the ISO 4217 3-letter code for this currency object.

getDefaultFractionDigits

Added in API level 24
open fun getDefaultFractionDigits(): Int

Returns the number of the number of fraction digits that should be displayed for this currency. This is equivalent to getDefaultFractionDigits(CurrencyUsage.STANDARD); Important: The number of fraction digits for a given currency is NOT guaranteed to be constant across versions of ICU or CLDR. For example, do NOT use this value as a mechanism for deciding the magnitude used to store currency values in a database. You should use this value for display purposes only.

Return
Int a non-negative number of fraction digits to be displayed

getDefaultFractionDigits

Added in API level 24
open fun getDefaultFractionDigits(Usage: Currency.CurrencyUsage!): Int

Returns the number of the number of fraction digits that should be displayed for this currency with Usage. Important: The number of fraction digits for a given currency is NOT guaranteed to be constant across versions of ICU or CLDR. For example, do NOT use this value as a mechanism for deciding the magnitude used to store currency values in a database. You should use this value for display purposes only.

Parameters
Usage Currency.CurrencyUsage!: the usage of currency(Standard or Cash)
Return
Int a non-negative number of fraction digits to be displayed

getDisplayName

Added in API level 24
open fun getDisplayName(): String!

Returns the display name for this currency in the default locale. If the resource data for the default locale contains no entry for this currency, then the ISO 4217 code is returned.

Note: This method is a convenience equivalent for java.util.Currency#getDisplayName() and is equivalent to getName(Locale.getDefault(), LONG_NAME, null).

Return
String! The display name of this currency

getDisplayName

Added in API level 24
open fun getDisplayName(locale: Locale!): String!

Returns the display name for this currency in the given locale. If the resource data for the given locale contains no entry for this currency, then the ISO 4217 code is returned.

Note: This method is a convenience equivalent for java.util.Currency#getDisplayName(java.util.Locale) and is equivalent to getName(locale, LONG_NAME, null).

Parameters
locale Locale!: locale in which to display currency
Return
String! The display name of this currency for the specified locale

getInstance

Added in API level 24
open static fun getInstance(locale: ULocale!): Currency!

Returns a currency object for the default currency in the given locale.

getInstance

Added in API level 24
open static fun getInstance(theISOCode: String!): Currency!

Returns a currency object given an ISO 4217 3-letter code.

Parameters
theISOCode String!: the iso code
Return
Currency! the currency for this iso code
Exceptions
java.lang.NullPointerException if theISOCode is null.
java.lang.IllegalArgumentException if theISOCode is not a 3-letter alpha code.

getInstance

Added in API level 24
open static fun getInstance(locale: Locale!): Currency!

Returns a currency object for the default currency in the given locale.

Parameters
locale Locale!: the locale
Return
Currency! the currency object for this locale

getKeywordValuesForLocale

Added in API level 24
static fun getKeywordValuesForLocale(
    key: String!,
    locale: ULocale!,
    commonlyUsed: Boolean
): Array<String!>!

Given a key and a locale, returns an array of values for the key for which data exists. If commonlyUsed is true, these are the values that typically are used with this locale, otherwise these are all values for which data exists. This is a common service API.

The only supported key is "currency", other values return an empty array.

Currency information is based on the region of the locale. If the locale does not indicate a region, ULocale.addLikelySubtags(ULocale) is used to infer a region, except for the 'und' locale.

If commonlyUsed is true, only the currencies known to be in use as of the current date are returned. When there are more than one, these are returned in preference order (typically, this occurs when a country is transitioning to a new currency, and the newer currency is preferred), see Unicode TR#35 Sec. C1. If commonlyUsed is false, all currencies ever used in any locale are returned, in no particular order.

Parameters
key String!: key whose values to look up. the only recognized key is "currency"
locale ULocale!: the locale
commonlyUsed Boolean: if true, return only values that are currently used in the locale. Otherwise returns all values.
Return
Array<String!>! an array of values for the given key and the locale. If there is no data, the array will be empty.

getName

Added in API level 24
open fun getName(
    locale: ULocale!,
    nameStyle: Int,
    isChoiceFormat: BooleanArray!
): String!

Returns the display name for the given currency in the given locale. For example, the display name for the USD currency object in the en_US locale is "$".

Parameters
locale ULocale!: locale in which to display currency
nameStyle Int: selector for which kind of name to return. The nameStyle should be SYMBOL_NAME, NARROW_SYMBOL_NAME, or LONG_NAME. Otherwise, throw IllegalArgumentException.
isChoiceFormat BooleanArray!: isChoiceFormat[0] is always set to false, or isChoiceFormat can be null; display names are static strings; since ICU 4.4, ChoiceFormat patterns are no longer supported
Return
String! display string for this currency. If the resource data contains no entry for this currency, then the ISO 4217 code is returned.

Exceptions
java.lang.IllegalArgumentException if the nameStyle is not SYMBOL_NAME or LONG_NAME.

getName

Added in API level 24
open fun getName(
    locale: ULocale!,
    nameStyle: Int,
    pluralCount: String!,
    isChoiceFormat: BooleanArray!
): String!

Returns the display name for the given currency in the given locale. For example, the SYMBOL_NAME for the USD currency object in the en_US locale is "$". The PLURAL_LONG_NAME for the USD currency object when the currency amount is plural is "US dollars", such as in "3.00 US dollars"; while the PLURAL_LONG_NAME for the USD currency object when the currency amount is singular is "US dollar", such as in "1.00 US dollar".

Parameters
locale ULocale!: locale in which to display currency
nameStyle Int: selector for which kind of name to return
pluralCount String!: plural count string for this locale
isChoiceFormat BooleanArray!: isChoiceFormat[0] is always set to false, or isChoiceFormat can be null; display names are static strings; since ICU 4.4, ChoiceFormat patterns are no longer supported
Return
String! display string for this currency. If the resource data contains no entry for this currency, then the ISO 4217 code is returned.
Exceptions
java.lang.IllegalArgumentException if the nameStyle is not SYMBOL_NAME, LONG_NAME, or PLURAL_LONG_NAME.

getName

Added in API level 24
open fun getName(
    locale: Locale!,
    nameStyle: Int,
    isChoiceFormat: BooleanArray!
): String!

Returns the display name for the given currency in the given locale. This is a convenient method for getName(ULocale, int, boolean[]);

Parameters
locale Locale!: locale in which to display currency
nameStyle Int: selector for which kind of name to return. The nameStyle should be SYMBOL_NAME, NARROW_SYMBOL_NAME, or LONG_NAME. Otherwise, throw IllegalArgumentException.
isChoiceFormat BooleanArray!: isChoiceFormat[0] is always set to false, or isChoiceFormat can be null; display names are static strings; since ICU 4.4, ChoiceFormat patterns are no longer supported
Return
String! display string for this currency. If the resource data contains no entry for this currency, then the ISO 4217 code is returned.

getName

Added in API level 24
open fun getName(
    locale: Locale!,
    nameStyle: Int,
    pluralCount: String!,
    isChoiceFormat: BooleanArray!
): String!

Returns the display name for the given currency in the given locale. This is a convenience overload of getName(ULocale, int, String, boolean[]);

Parameters
locale Locale!: locale in which to display currency
nameStyle Int: selector for which kind of name to return
pluralCount String!: plural count string for this locale
isChoiceFormat BooleanArray!: isChoiceFormat[0] is always set to false, or isChoiceFormat can be null; display names are static strings; since ICU 4.4, ChoiceFormat patterns are no longer supported
Return
String! display string for this currency. If the resource data contains no entry for this currency, then the ISO 4217 code is returned.

getNumericCode

Added in API level 24
open fun getNumericCode(): Int

Returns the ISO 4217 numeric code for this currency object.

Note: If the ISO 4217 numeric code is not assigned for the currency or the currency is unknown, this method returns 0.

Return
Int The ISO 4217 numeric code of this currency.

getRoundingIncrement

Added in API level 24
open fun getRoundingIncrement(): Double

Returns the rounding increment for this currency, or 0.0 if no rounding is done by this currency. This is equivalent to getRoundingIncrement(CurrencyUsage.STANDARD);

Return
Double the non-negative rounding increment, or 0.0 if none

getRoundingIncrement

Added in API level 24
open fun getRoundingIncrement(Usage: Currency.CurrencyUsage!): Double

Returns the rounding increment for this currency, or 0.0 if no rounding is done by this currency with the Usage.

Parameters
Usage Currency.CurrencyUsage!: the usage of currency(Standard or Cash)
Return
Double the non-negative rounding increment, or 0.0 if none

getSymbol

Added in API level 24
open fun getSymbol(): String!

Convenience and compatibility override of getName that requests the symbol name for the default DISPLAY locale.

getSymbol

Added in API level 24
open fun getSymbol(uloc: ULocale!): String!

Convenience and compatibility override of getName that requests the symbol name.

Parameters
uloc ULocale!: the ULocale for the symbol

See Also

    getSymbol

    Added in API level 24
    open fun getSymbol(loc: Locale!): String!

    Convenience and compatibility override of getName that requests the symbol name.

    Parameters
    loc Locale!: the Locale for the symbol

    See Also

      isAvailable

      Added in API level 24
      open static fun isAvailable(
          code: String!,
          from: Date!,
          to: Date!
      ): Boolean

      Queries if the given ISO 4217 3-letter code is available on the specified date range.

      Note: For checking availability of a currency on a specific date, specify the date on both from and to. When both from and to are null, this method checks if the specified currency is available all time.

      Parameters
      code String!: The ISO 4217 3-letter code.
      from Date!: The lower bound of the date range, inclusive. When from is null, check the availability of the currency any date before to
      to Date!: The upper bound of the date range, inclusive. When to is null, check the availability of the currency any date after from
      Return
      Boolean true if the given ISO 4217 3-letter code is supported on the specified date range.
      Exceptions
      java.lang.IllegalArgumentException when to is before from.

      toJavaCurrency

      Added in API level 29
      open fun toJavaCurrency(): Currency!

      Returns a java.util.Currency object based on the currency represented by this Currency.

      Return
      Currency! An equivalent Java currency object.

      toString

      Added in API level 24
      open fun toString(): String

      Returns the ISO 4217 code for this currency.

      Return
      String a string representation of the object.