Class Currency
- All Implemented Interfaces:
Serializable
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
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.
- Author:
- Alan Liu
- See Also:
- Status:
- Stable ICU 2.2.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classDeprecated.This API is ICU internal only.static enumCurrency Usage used for Decimal FormatNested classes/interfaces inherited from class MeasureUnit
MeasureUnit.Complexity, MeasureUnit.Factory, MeasureUnit.MeasurePrefixModifier and TypeClassDescriptionstatic enumEnumeration for unit complexity.protected static interfaceDeprecated.This API is ICU internal only.static enumEnumeration for SI and binary prefixes, e.g. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intSelector for getName() indicating the formal currency symbol.static final intSelector for getName() indicating the long name for a currency, such as "US Dollar" for USD.static final intSelector for getName() indicating the narrow currency symbol.static final intSelector 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 final intSelector for getName() indicating a symbolic name for a currency, such as "$" for USD.static final intSelector for getName() indicating the variant currency symbol.Fields inherited from class MeasureUnit
ACRE, ACRE_FOOT, AMPERE, ARC_MINUTE, ARC_SECOND, ASTRONOMICAL_UNIT, ATMOSPHERE, BAR, BARREL, BEAUFORT, BECQUEREL, BIT, BRITISH_THERMAL_UNIT, BRITISH_THERMAL_UNIT_IT, BU_JP, BUSHEL, BYTE, CALORIE, CALORIE_IT, CANDELA, CARAT, CELSIUS, CENTILITER, CENTIMETER, CENTURY, CHAIN, CHO, COULOMB, CUBIC_CENTIMETER, CUBIC_FOOT, CUBIC_INCH, CUBIC_KILOMETER, CUBIC_METER, CUBIC_MILE, CUBIC_YARD, CUP, CUP_IMPERIAL, CUP_JP, CUP_METRIC, DALTON, DAY, DAY_PERSON, DECADE, DECILITER, DECIMETER, DEGREE, DESSERT_SPOON, DESSERT_SPOON_IMPERIAL, DOT, DOT_PER_CENTIMETER, DOT_PER_INCH, DRAM, DROP, DUNAM, DYNE, EARTH_MASS, EARTH_RADIUS, ELECTRONVOLT, EM, FAHRENHEIT, FARAD, FATHOM, FLUID_OUNCE, FLUID_OUNCE_IMPERIAL, FLUID_OUNCE_METRIC, FOODCALORIE, FOOT, FORTNIGHT, FUN, FURLONG, G_FORCE, GALLON, GALLON_IMPERIAL, GASOLINE_ENERGY_DENSITY, GENERIC_TEMPERATURE, GIGABIT, GIGABYTE, GIGAHERTZ, GIGAWATT, GRAIN, GRAM, GRAY, HECTARE, HECTOLITER, HECTOPASCAL, HENRY, HERTZ, HORSEPOWER, HOUR, INCH, INCH_HG, ITEM, JIGGER, JO_JP, JOULE, KARAT, KATAL, KELVIN, KEN, KILOBIT, KILOBYTE, KILOCALORIE, KILOGRAM, KILOGRAM_FORCE, KILOHERTZ, KILOJOULE, KILOMETER, KILOMETER_PER_HOUR, KILOPASCAL, KILOWATT, KILOWATT_HOUR, KILOWATT_HOUR_PER_100_KILOMETER, KNOT, KOKU, KOSAJI, LIGHT_SPEED, LIGHT_YEAR, LITER, LITER_PER_100KILOMETERS, LITER_PER_KILOMETER, LUMEN, LUX, MEGABIT, MEGABYTE, MEGAHERTZ, MEGALITER, MEGAPASCAL, MEGAPIXEL, MEGAWATT, METER, METER_PER_SECOND, METER_PER_SECOND_SQUARED, METRIC_TON, MICROGRAM, MICROMETER, MICROSECOND, MILE, MILE_PER_GALLON, MILE_PER_GALLON_IMPERIAL, MILE_PER_HOUR, MILE_SCANDINAVIAN, MILLIAMPERE, MILLIBAR, MILLIGRAM, MILLIGRAM_OFGLUCOSE_PER_DECILITER, MILLIGRAM_PER_DECILITER, MILLIINCH, MILLILITER, MILLIMETER, MILLIMETER_OF_MERCURY, MILLIMOLE_PER_LITER, MILLISECOND, MILLIWATT, MINUTE, MOLE, MONTH, MONTH_PERSON, NANOMETER, NANOSECOND, NAUTICAL_MILE, NEWTON, NEWTON_METER, NIGHT, OFGLUCOSE, OFHG, OHM, OSAJI, OUNCE, OUNCE_TROY, PARSEC, PART, PART_PER_1E6, PART_PER_1E9, PART_PER_MILLION, PASCAL, PERCENT, PERMILLE, PERMYRIAD, PETABYTE, PICOMETER, PINCH, PINT, PINT_IMPERIAL, PINT_METRIC, PIXEL, PIXEL_PER_CENTIMETER, PIXEL_PER_INCH, POINT, POUND, POUND_FOOT, POUND_FORCE, POUND_PER_SQUARE_INCH, POUNDAL, QUART, QUART_IMPERIAL, QUARTER, RADIAN, RANKINE, REVOLUTION_ANGLE, RI_JP, RIN, ROD, SAI, SE_JP, SECOND, SHAKU, SHAKU_CLOTH, SHAKU_LENGTH, SIEMENS, SIEVERT, SLUG, SOLAR_LUMINOSITY, SOLAR_MASS, SOLAR_RADIUS, SQUARE_CENTIMETER, SQUARE_FOOT, SQUARE_INCH, SQUARE_KILOMETER, SQUARE_METER, SQUARE_MILE, SQUARE_YARD, STERADIAN, STONE, subType, SUN, TABLESPOON, TEASPOON, TERABIT, TERABYTE, TESLA, THERM_US, TO_JP, TON, TONNE, type, VOLT, WATT, WEBER, WEEK, WEEK_PERSON, YARD, YEAR, YEAR_PERSONModifier and TypeFieldDescriptionstatic final MeasureUnitConstant for unit of area: acrestatic final MeasureUnitConstant for unit of volume: acre-footstatic final MeasureUnitConstant for unit of electric: amperestatic final MeasureUnitConstant for unit of angle: arc-minutestatic final MeasureUnitConstant for unit of angle: arc-secondstatic final MeasureUnitConstant for unit of length: astronomical-unitstatic final MeasureUnitConstant for unit of pressure: atmospherestatic final MeasureUnitConstant for unit of pressure: barstatic final MeasureUnitConstant for unit of volume: barrelstatic final MeasureUnitConstant for unit of speed: beaufortstatic final MeasureUnitConstant for unit of energy: becquerelstatic final MeasureUnitConstant for unit of digital: bitstatic final MeasureUnitConstant for unit of energy: british-thermal-unitstatic final MeasureUnitConstant for unit of energy: british-thermal-unit-itstatic final MeasureUnitConstant for unit of area: bu-jpstatic final MeasureUnitConstant for unit of volume: bushelstatic final MeasureUnitConstant for unit of digital: bytestatic final MeasureUnitConstant for unit of energy: caloriestatic final MeasureUnitConstant for unit of energy: calorie-itstatic final MeasureUnitConstant for unit of light: candelastatic final MeasureUnitConstant for unit of mass: caratstatic final MeasureUnitConstant for unit of temperature: celsiusstatic final MeasureUnitConstant for unit of volume: centiliterstatic final MeasureUnitConstant for unit of length: centimeterstatic final MeasureUnitConstant for unit of duration: centurystatic final MeasureUnitConstant for unit of length: chainstatic final MeasureUnitConstant for unit of area: chostatic final MeasureUnitConstant for unit of electric: coulombstatic final MeasureUnitConstant for unit of volume: cubic-centimeterstatic final MeasureUnitConstant for unit of volume: cubic-footstatic final MeasureUnitConstant for unit of volume: cubic-inchstatic final MeasureUnitConstant for unit of volume: cubic-kilometerstatic final MeasureUnitConstant for unit of volume: cubic-meterstatic final MeasureUnitConstant for unit of volume: cubic-milestatic final MeasureUnitConstant for unit of volume: cubic-yardstatic final MeasureUnitConstant for unit of volume: cupstatic final MeasureUnitConstant for unit of volume: cup-imperialstatic final MeasureUnitConstant for unit of volume: cup-jpstatic final MeasureUnitConstant for unit of volume: cup-metricstatic final MeasureUnitConstant for unit of mass: daltonstatic final TimeUnitConstant for unit of duration: daystatic final MeasureUnitConstant for unit of duration: day-personstatic final MeasureUnitConstant for unit of duration: decadestatic final MeasureUnitConstant for unit of volume: deciliterstatic final MeasureUnitConstant for unit of length: decimeterstatic final MeasureUnitConstant for unit of angle: degreestatic final MeasureUnitConstant for unit of volume: dessert-spoonstatic final MeasureUnitConstant for unit of volume: dessert-spoon-imperialstatic final MeasureUnitConstant for unit of graphics: dotstatic final MeasureUnitConstant for unit of graphics: dot-per-centimeterstatic final MeasureUnitConstant for unit of graphics: dot-per-inchstatic final MeasureUnitConstant for unit of volume: dramstatic final MeasureUnitConstant for unit of volume: dropstatic final MeasureUnitConstant for unit of area: dunamstatic final MeasureUnitConstant for unit of force: dynestatic final MeasureUnitConstant for unit of mass: earth-massstatic final MeasureUnitConstant for unit of length: earth-radiusstatic final MeasureUnitConstant for unit of energy: electronvoltstatic final MeasureUnitConstant for unit of graphics: emstatic final MeasureUnitConstant for unit of temperature: fahrenheitstatic final MeasureUnitConstant for unit of electric: faradstatic final MeasureUnitConstant for unit of length: fathomstatic final MeasureUnitConstant for unit of volume: fluid-ouncestatic final MeasureUnitConstant for unit of volume: fluid-ounce-imperialstatic final MeasureUnitConstant for unit of volume: fluid-ounce-metricstatic final MeasureUnitConstant for unit of energy: foodcaloriestatic final MeasureUnitConstant for unit of length: footstatic final MeasureUnitConstant for unit of duration: fortnightstatic final MeasureUnitConstant for unit of mass: funstatic final MeasureUnitConstant for unit of length: furlongstatic final MeasureUnitConstant for unit of acceleration: g-forcestatic final MeasureUnitConstant for unit of volume: gallonstatic final MeasureUnitConstant for unit of volume: gallon-imperialstatic final MeasureUnitConstant for unit of pressure: gasoline-energy-densitystatic final MeasureUnitConstant for unit of temperature: genericstatic final MeasureUnitConstant for unit of digital: gigabitstatic final MeasureUnitConstant for unit of digital: gigabytestatic final MeasureUnitConstant for unit of frequency: gigahertzstatic final MeasureUnitConstant for unit of power: gigawattstatic final MeasureUnitConstant for unit of mass: grainstatic final MeasureUnitConstant for unit of mass: gramstatic final MeasureUnitConstant for unit of energy: graystatic final MeasureUnitConstant for unit of area: hectarestatic final MeasureUnitConstant for unit of volume: hectoliterstatic final MeasureUnitConstant for unit of pressure: hectopascalstatic final MeasureUnitConstant for unit of electric: henrystatic final MeasureUnitConstant for unit of frequency: hertzstatic final MeasureUnitConstant for unit of power: horsepowerstatic final TimeUnitConstant for unit of duration: hourstatic final MeasureUnitConstant for unit of length: inchstatic final MeasureUnitConstant for unit of pressure: inch-ofhgstatic final MeasureUnitConstant for unit of concentr: itemstatic final MeasureUnitConstant for unit of volume: jiggerstatic final MeasureUnitConstant for unit of length: jo-jpstatic final MeasureUnitConstant for unit of energy: joulestatic final MeasureUnitConstant for unit of concentr: karatstatic final MeasureUnitConstant for unit of concentr: katalstatic final MeasureUnitConstant for unit of temperature: kelvinstatic final MeasureUnitConstant for unit of length: kenstatic final MeasureUnitConstant for unit of digital: kilobitstatic final MeasureUnitConstant for unit of digital: kilobytestatic final MeasureUnitConstant for unit of energy: kilocaloriestatic final MeasureUnitConstant for unit of mass: kilogramstatic final MeasureUnitConstant for unit of force: kilogram-forcestatic final MeasureUnitConstant for unit of frequency: kilohertzstatic final MeasureUnitConstant for unit of energy: kilojoulestatic final MeasureUnitConstant for unit of length: kilometerstatic final MeasureUnitConstant for unit of speed: kilometer-per-hourstatic final MeasureUnitConstant for unit of pressure: kilopascalstatic final MeasureUnitConstant for unit of power: kilowattstatic final MeasureUnitConstant for unit of energy: kilowatt-hourstatic final MeasureUnitConstant for unit of force: kilowatt-hour-per-100-kilometerstatic final MeasureUnitConstant for unit of speed: knotstatic final MeasureUnitConstant for unit of volume: kokustatic final MeasureUnitConstant for unit of volume: kosajistatic final MeasureUnitConstant for unit of speed: light-speedstatic final MeasureUnitConstant for unit of length: light-yearstatic final MeasureUnitConstant for unit of volume: literstatic final MeasureUnitConstant for unit of consumption: liter-per-100-kilometerstatic final MeasureUnitConstant for unit of consumption: liter-per-kilometerstatic final MeasureUnitConstant for unit of light: lumenstatic final MeasureUnitConstant for unit of light: luxstatic final MeasureUnitConstant for unit of digital: megabitstatic final MeasureUnitConstant for unit of digital: megabytestatic final MeasureUnitConstant for unit of frequency: megahertzstatic final MeasureUnitConstant for unit of volume: megaliterstatic final MeasureUnitConstant for unit of pressure: megapascalstatic final MeasureUnitConstant for unit of graphics: megapixelstatic final MeasureUnitConstant for unit of power: megawattstatic final MeasureUnitConstant for unit of length: meterstatic final MeasureUnitConstant for unit of speed: meter-per-secondstatic final MeasureUnitConstant for unit of acceleration: meter-per-square-secondstatic final MeasureUnitDeprecated.ICU 78 use TONNEstatic final MeasureUnitConstant for unit of mass: microgramstatic final MeasureUnitConstant for unit of length: micrometerstatic final MeasureUnitConstant for unit of duration: microsecondstatic final MeasureUnitConstant for unit of length: milestatic final MeasureUnitConstant for unit of consumption: mile-per-gallonstatic final MeasureUnitConstant for unit of consumption: mile-per-gallon-imperialstatic final MeasureUnitConstant for unit of speed: mile-per-hourstatic final MeasureUnitConstant for unit of length: mile-scandinavianstatic final MeasureUnitConstant for unit of electric: milliamperestatic final MeasureUnitConstant for unit of pressure: millibarstatic final MeasureUnitConstant for unit of mass: milligramstatic final MeasureUnitConstant for unit of concentr: milligram-ofglucose-per-deciliterstatic final MeasureUnitDeprecated.ICU 78 use MILLIGRAM_OFGLUCOSE_PER_DECILITERstatic final MeasureUnitConstant for unit of length: milliinchstatic final MeasureUnitConstant for unit of volume: milliliterstatic final MeasureUnitConstant for unit of length: millimeterstatic final MeasureUnitConstant for unit of pressure: millimeter-ofhgstatic final MeasureUnitConstant for unit of concentr: millimole-per-literstatic final MeasureUnitConstant for unit of duration: millisecondstatic final MeasureUnitConstant for unit of power: milliwattstatic final TimeUnitConstant for unit of duration: minutestatic final MeasureUnitConstant for unit of concentr: molestatic final TimeUnitConstant for unit of duration: monthstatic final MeasureUnitConstant for unit of duration: month-personstatic final MeasureUnitConstant for unit of length: nanometerstatic final MeasureUnitConstant for unit of duration: nanosecondstatic final MeasureUnitConstant for unit of length: nautical-milestatic final MeasureUnitConstant for unit of force: newtonstatic final MeasureUnitConstant for unit of torque: newton-meterstatic final MeasureUnitConstant for unit of duration: nightstatic final MeasureUnitConstant for unit of concentr: ofglucosestatic final MeasureUnitConstant for unit of pressure: ofhgstatic final MeasureUnitConstant for unit of electric: ohmstatic final MeasureUnitConstant for unit of volume: osajistatic final MeasureUnitConstant for unit of mass: ouncestatic final MeasureUnitConstant for unit of mass: ounce-troystatic final MeasureUnitConstant for unit of length: parsecstatic final MeasureUnitConstant for unit of concentr: partstatic final MeasureUnitConstant for unit of concentr: part-per-1e6static final MeasureUnitConstant for unit of concentr: part-per-1e9static final MeasureUnitConstant for unit of concentr: part-per-million (renamed to part-per-1e6 in CLDR 48 / ICU 78).static final MeasureUnitConstant for unit of pressure: pascalstatic final MeasureUnitConstant for unit of concentr: percentstatic final MeasureUnitConstant for unit of concentr: permillestatic final MeasureUnitConstant for unit of concentr: permyriadstatic final MeasureUnitConstant for unit of digital: petabytestatic final MeasureUnitConstant for unit of length: picometerstatic final MeasureUnitConstant for unit of volume: pinchstatic final MeasureUnitConstant for unit of volume: pintstatic final MeasureUnitConstant for unit of volume: pint-imperialstatic final MeasureUnitConstant for unit of volume: pint-metricstatic final MeasureUnitConstant for unit of graphics: pixelstatic final MeasureUnitConstant for unit of graphics: pixel-per-centimeterstatic final MeasureUnitConstant for unit of graphics: pixel-per-inchstatic final MeasureUnitConstant for unit of length: pointstatic final MeasureUnitConstant for unit of mass: poundstatic final MeasureUnitConstant for unit of torque: pound-force-footstatic final MeasureUnitConstant for unit of force: pound-forcestatic final MeasureUnitConstant for unit of pressure: pound-force-per-square-inchstatic final MeasureUnitConstant for unit of force: poundalstatic final MeasureUnitConstant for unit of volume: quartstatic final MeasureUnitConstant for unit of volume: quart-imperialstatic final MeasureUnitConstant for unit of duration: quarterstatic final MeasureUnitConstant for unit of angle: radianstatic final MeasureUnitConstant for unit of temperature: rankinestatic final MeasureUnitConstant for unit of angle: revolutionstatic final MeasureUnitConstant for unit of length: ri-jpstatic final MeasureUnitConstant for unit of length: rinstatic final MeasureUnitConstant for unit of length: rodstatic final MeasureUnitConstant for unit of volume: saistatic final MeasureUnitConstant for unit of area: se-jpstatic final TimeUnitConstant for unit of duration: secondstatic final MeasureUnitConstant for unit of volume: shakustatic final MeasureUnitConstant for unit of length: shaku-clothstatic final MeasureUnitConstant for unit of length: shaku-lengthstatic final MeasureUnitConstant for unit of electric: siemensstatic final MeasureUnitConstant for unit of energy: sievertstatic final MeasureUnitConstant for unit of mass: slugstatic final MeasureUnitConstant for unit of light: solar-luminositystatic final MeasureUnitConstant for unit of mass: solar-massstatic final MeasureUnitConstant for unit of length: solar-radiusstatic final MeasureUnitConstant for unit of area: square-centimeterstatic final MeasureUnitConstant for unit of area: square-footstatic final MeasureUnitConstant for unit of area: square-inchstatic final MeasureUnitConstant for unit of area: square-kilometerstatic final MeasureUnitConstant for unit of area: square-meterstatic final MeasureUnitConstant for unit of area: square-milestatic final MeasureUnitConstant for unit of area: square-yardstatic final MeasureUnitConstant for unit of angle: steradianstatic final MeasureUnitConstant for unit of mass: stoneprotected final StringDeprecated.This API is ICU internal only.static final MeasureUnitConstant for unit of length: sunstatic final MeasureUnitConstant for unit of volume: tablespoonstatic final MeasureUnitConstant for unit of volume: teaspoonstatic final MeasureUnitConstant for unit of digital: terabitstatic final MeasureUnitConstant for unit of digital: terabytestatic final MeasureUnitConstant for unit of magnetic: teslastatic final MeasureUnitConstant for unit of energy: therm-usstatic final MeasureUnitConstant for unit of volume: to-jpstatic final MeasureUnitConstant for unit of mass: tonstatic final MeasureUnitConstant for unit of mass: tonneprotected final StringDeprecated.This API is ICU internal only.static final MeasureUnitConstant for unit of electric: voltstatic final MeasureUnitConstant for unit of power: wattstatic final MeasureUnitConstant for unit of magnetic: weberstatic final TimeUnitConstant for unit of duration: weekstatic final MeasureUnitConstant for unit of duration: week-personstatic final MeasureUnitConstant for unit of length: yardstatic final TimeUnitConstant for unit of duration: yearstatic final MeasureUnitConstant for unit of duration: year-person -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic CurrencyfromJavaCurrency(Currency currency) Returns a Currency object based on the currency represented by the given java.util.Currency.Returns the set of available currencies.static String[]getAvailableCurrencyCodes(ULocale loc, Date d) Returns an array of Strings which contain the currency identifiers that are valid for the given locale on the given date.static String[]getAvailableCurrencyCodes(Locale loc, Date d) Returns an array of Strings which contain the currency identifiers that are valid for the givenLocaleon the given date.static Locale[]Return an array of the locales for which a currency is defined.static ULocale[]Return an array of the ulocales for which a currency is defined.Returns the ISO 4217 3-letter code for this currency object.intReturns the number of the number of fraction digits that should be displayed for this currency.intReturns the number of the number of fraction digits that should be displayed for this currency with Usage.Returns the display name for this currency in the default locale.getDisplayName(Locale locale) Returns the display name for this currency in the given locale.static CurrencygetInstance(ULocale locale) Returns a currency object for the default currency in the given locale.static CurrencygetInstance(String theISOCode) Returns a currency object given an ISO 4217 3-letter code.static CurrencygetInstance(Locale locale) Returns a currency object for the default currency in the given locale.static final String[]getKeywordValuesForLocale(String key, ULocale locale, boolean commonlyUsed) Given a key and a locale, returns an array of values for the key for which data exists.Returns the display name for the given currency in the given locale.Returns the display name for the given currency in the given locale.Returns the display name for the given currency in the given locale.Returns the display name for the given currency in the given locale.intReturns the ISO 4217 numeric code for this currency object.static com.ibm.icu.impl.TextTrieMap<Currency.CurrencyStringInfo> getParsingTrie(ULocale locale, int type) Deprecated.This API is ICU internal only.doubleReturns the rounding increment for this currency, or 0.0 if no rounding is done by this currency.doubleReturns the rounding increment for this currency, or 0.0 if no rounding is done by this currency with the Usage.Convenience and compatibility override of getName that requests the symbol name for the defaultDISPLAYlocale.Convenience and compatibility override of getName that requests the symbol name.Convenience and compatibility override of getName that requests the symbol name.static booleanisAvailable(String code, Date from, Date to) Queries if the given ISO 4217 3-letter code is available on the specified date range.static Stringparse(ULocale locale, String text, int type, ParsePosition pos) Deprecated.This API is ICU internal only.static ObjectregisterInstance(Currency currency, ULocale locale) Registers a new currency for the provided locale.Returns a java.util.Currency object based on the currency represented by this Currency.toString()Returns the ISO 4217 code for this currency.static booleanunregister(Object registryKey) Unregister the currency associated with this key (obtained from registerInstance).Methods inherited from class MeasureUnit
addUnit, equals, findBySubType, forIdentifier, fromMeasureUnitImpl, getAvailable, getAvailable, getAvailableTypes, getComplexity, getConstantDenominator, getCopyOfMeasureUnitImpl, getDimensionality, getIdentifier, getPrefix, getSubtype, getType, getUnit, hashCode, internalGetInstance, product, reciprocal, splitToSingleUnits, validateAndGet, withConstantDenominator, withDimensionality, withPrefixModifier and TypeMethodDescriptionprotected static MeasureUnitaddUnit(String type, String unitName, MeasureUnit.Factory factory) Deprecated.This API is ICU internal only.booleanstatic MeasureUnitfindBySubType(String subType) Deprecated.This API is ICU internal only.static MeasureUnitforIdentifier(String identifier) Constructs a MeasureUnit from a CLDR Core Unit Identifier, as defined in UTS 35.static MeasureUnitfromMeasureUnitImpl(com.ibm.icu.impl.units.MeasureUnitImpl measureUnitImpl) Deprecated.Internal API for ICU use only.static Set<MeasureUnit> Get all of the available units.static Set<MeasureUnit> getAvailable(String type) For the given type, return the available units.Get all of the available units' types.Compute the complexity of the unit.longRetrieves the constant denominator for this COMPOUND unit.com.ibm.icu.impl.units.MeasureUnitImplDeprecated.This API is ICU internal only.intReturns the dimensionality (power) of this MeasureUnit.Get CLDR Unit Identifier for this MeasureUnit, as defined in UTS 35.Returns the current SI or binary prefix of this SINGLE unit.Get the subType, such as “foot”.getType()Get the type, such as "length".static MeasureUnitDeprecated.This API is ICU internal only.inthashCode()static MeasureUnitinternalGetInstance(String type, String subType) Deprecated.This API is ICU internal only.product(MeasureUnit other) Computes the product of this unit with another unit.Computes the reciprocal of this MeasureUnit, with the numerator and denominator flipped.Returns the list of SINGLE units contained within a sequence of COMPOUND units.static MeasureUnitvalidateAndGet(String type, String subtype) Deprecated.This API is ICU internal only.withConstantDenominator(long denominator) Creates a new MeasureUnit with a specified constant denominator.withDimensionality(int dimensionality) Creates a MeasureUnit which is this SINGLE unit augmented with the specified dimensionality (power).withPrefix(MeasureUnit.MeasurePrefix prefix) Creates a MeasureUnit which is this SINGLE unit augmented with the specified prefix.
-
Field Details
-
SYMBOL_NAME
public static final int SYMBOL_NAMESelector for getName() indicating a symbolic name for a currency, such as "$" for USD.- See Also:
- Status:
- Stable ICU 2.6.
-
LONG_NAME
public static final int LONG_NAMESelector for getName() indicating the long name for a currency, such as "US Dollar" for USD.- See Also:
- Status:
- Stable ICU 2.6.
-
PLURAL_LONG_NAME
public static final int PLURAL_LONG_NAMESelector 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".- See Also:
- Status:
- Stable ICU 4.2.
-
NARROW_SYMBOL_NAME
public static final int NARROW_SYMBOL_NAMESelector 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.
- See Also:
- Status:
- Stable ICU 61.
-
FORMAL_SYMBOL_NAME
public static final int FORMAL_SYMBOL_NAMESelector 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.
- See Also:
- Status:
- Stable ICU 67.
-
VARIANT_SYMBOL_NAME
public static final int VARIANT_SYMBOL_NAMESelector 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.
- See Also:
- Status:
- Stable ICU 67.
-
-
Constructor Details
-
Currency
Constructs a currency object for the given ISO 4217 3-letter code. This constructor assumes that the code is valid.- Parameters:
theISOCode- The iso code used to construct the currency.- Status:
- Stable ICU 3.4.
-
-
Method Details
-
getInstance
-
getInstance
-
getAvailableCurrencyCodes
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- the locale for which to retrieve currency codes.d- the date for which to retrieve currency codes for the given locale.- Returns:
- The array of ISO currency codes.
- Status:
- Stable ICU 4.0.
-
getAvailableCurrencyCodes
Returns an array of Strings which contain the currency identifiers that are valid for the givenLocaleon the given date. If there are no such identifiers, returns null. Returned identifiers are in preference order.- Parameters:
loc- theLocalefor which to retrieve currency codes.d- the date for which to retrieve currency codes for the given locale.- Returns:
- The array of ISO currency codes.
- Status:
- Stable ICU 54.
-
getAvailableCurrencies
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.- Returns:
- The set of available currencies. The returned set could be empty if there is no currency data available.
- Status:
- Stable ICU 49.
-
getInstance
Returns a currency object given an ISO 4217 3-letter code.- Parameters:
theISOCode- the iso code- Returns:
- the currency for this iso code
- Throws:
NullPointerException- iftheISOCodeis null.IllegalArgumentException- iftheISOCodeis not a 3-letter alpha code.- Status:
- Stable ICU 2.2.
-
fromJavaCurrency
-
toJavaCurrency
Returns a java.util.Currency object based on the currency represented by this Currency.- Returns:
- An equivalent Java currency object.
- Status:
- Stable ICU 60.
-
registerInstance
Registers a new currency for the provided locale. The returned object is a key that can be used to unregister this currency object.Because ICU may choose to cache Currency objects internally, this must be called at application startup, prior to any calls to Currency.getInstance to avoid undefined behavior.
- Parameters:
currency- the currency to registerlocale- the ulocale under which to register the currency- Returns:
- a registry key that can be used to unregister this currency
- See Also:
- Status:
- Stable ICU 3.2.
-
unregister
Unregister the currency associated with this key (obtained from registerInstance).- Parameters:
registryKey- the registry key returned from registerInstance- See Also:
- Status:
- Stable ICU 2.6.
-
getAvailableLocales
Return an array of the locales for which a currency is defined.- Returns:
- an array of the available locales
- Status:
- Stable ICU 2.2.
-
getAvailableULocales
Return an array of the ulocales for which a currency is defined.- Returns:
- an array of the available ulocales
- Status:
- Stable ICU 3.2.
-
getKeywordValuesForLocale
public static final String[] getKeywordValuesForLocale(String key, ULocale locale, boolean commonlyUsed) 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- key whose values to look up. the only recognized key is "currency"locale- the localecommonlyUsed- if true, return only values that are currently used in the locale. Otherwise returns all values.- Returns:
- an array of values for the given key and the locale. If there is no data, the array will be empty.
- Status:
- Stable ICU 4.2.
-
getCurrencyCode
Returns the ISO 4217 3-letter code for this currency object.- Status:
- Stable ICU 2.2.
-
getNumericCode
public int getNumericCode()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.
- Returns:
- The ISO 4217 numeric code of this currency.
- Status:
- Stable ICU 49.
-
getSymbol
Convenience and compatibility override of getName that requests the symbol name for the defaultDISPLAYlocale.- See Also:
- Status:
- Stable ICU 3.4.
-
getSymbol
-
getSymbol
-
getName
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 in which to display currencynameStyle- selector for which kind of name to return. The nameStyle should be SYMBOL_NAME, NARROW_SYMBOL_NAME, or LONG_NAME. Otherwise, throw IllegalArgumentException.isChoiceFormat- 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- Returns:
- display string for this currency. If the resource data contains no entry for this currency, then the ISO 4217 code is returned.
- Status:
- Stable ICU 3.2.
-
getName
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- locale in which to display currencynameStyle- selector for which kind of name to return. The nameStyle should be SYMBOL_NAME, NARROW_SYMBOL_NAME, or LONG_NAME. Otherwise, throw IllegalArgumentException.isChoiceFormat- 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- Returns:
- display string for this currency. If the resource data contains no entry for this currency, then the ISO 4217 code is returned.
- Throws:
IllegalArgumentException- if the nameStyle is not SYMBOL_NAME or LONG_NAME.- See Also:
- Status:
- Stable ICU 3.2.
-
getName
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 in which to display currencynameStyle- selector for which kind of name to returnpluralCount- plural count string for this localeisChoiceFormat- 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- Returns:
- display string for this currency. If the resource data contains no entry for this currency, then the ISO 4217 code is returned.
- Status:
- Stable ICU 4.2.
-
getName
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- locale in which to display currencynameStyle- selector for which kind of name to returnpluralCount- plural count string for this localeisChoiceFormat- 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- Returns:
- display string for this currency. If the resource data contains no entry for this currency, then the ISO 4217 code is returned.
- Throws:
IllegalArgumentException- if the nameStyle is not SYMBOL_NAME, LONG_NAME, or PLURAL_LONG_NAME.- Status:
- Stable ICU 4.2.
-
getDisplayName
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
Currency.getDisplayName()and is equivalent togetName(Locale.getDefault(), LONG_NAME, null).- Returns:
- The display name of this currency
- See Also:
- Status:
- Stable ICU 49.
-
getDisplayName
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
Currency.getDisplayName(java.util.Locale)and is equivalent togetName(locale, LONG_NAME, null).- Parameters:
locale- locale in which to display currency- Returns:
- The display name of this currency for the specified locale
- See Also:
- Status:
- Stable ICU 49.
-
parse
Deprecated.This API is ICU internal only.Attempt to parse the given string as a currency, either as a display name in the given locale, or as a 3-letter ISO 4217 code. If multiple display names match, then the longest one is selected. If both a display name and a 3-letter ISO code match, then the display name is preferred, unless it's length is less than 3.- Parameters:
locale- the locale of the display names to matchtext- the text to parsetype- parse against currency type: LONG_NAME only or notpos- input-output position; on input, the position within text to match; must have 0 <= pos.getIndex() < text.length(); on output, the position after the last matched character. If the parse fails, the position in unchanged upon output.- Returns:
- the ISO 4217 code, as a string, of the best match, or null if there is no match
- Status:
- Internal. This API is ICU internal only.
-
getParsingTrie
@Deprecated public static com.ibm.icu.impl.TextTrieMap<Currency.CurrencyStringInfo> getParsingTrie(ULocale locale, int type) Deprecated.This API is ICU internal only.- Status:
- Internal. This API is ICU internal only.
-
getDefaultFractionDigits
public int getDefaultFractionDigits()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.
- Returns:
- a non-negative number of fraction digits to be displayed
- Status:
- Stable ICU 2.2.
-
getDefaultFractionDigits
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- the usage of currency(Standard or Cash)- Returns:
- a non-negative number of fraction digits to be displayed
- Status:
- Stable ICU 54.
-
getRoundingIncrement
public double getRoundingIncrement()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);- Returns:
- the non-negative rounding increment, or 0.0 if none
- Status:
- Stable ICU 2.2.
-
getRoundingIncrement
Returns the rounding increment for this currency, or 0.0 if no rounding is done by this currency with the Usage.- Parameters:
Usage- the usage of currency(Standard or Cash)- Returns:
- the non-negative rounding increment, or 0.0 if none
- Status:
- Stable ICU 54.
-
toString
Returns the ISO 4217 code for this currency.- Overrides:
toStringin classMeasureUnit- Status:
- Stable ICU 2.2.
-
isAvailable
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
fromandto. When bothfromandtoare null, this method checks if the specified currency is available all time.- Parameters:
code- The ISO 4217 3-letter code.from- The lower bound of the date range, inclusive. Whenfromis null, check the availability of the currency any date beforetoto- The upper bound of the date range, inclusive. Whentois null, check the availability of the currency any date afterfrom- Returns:
- true if the given ISO 4217 3-letter code is supported on the specified date range.
- Throws:
IllegalArgumentException- whentois beforefrom.- Status:
- Stable ICU 4.6.
-