Class Currency
- java.lang.Object
-
- com.ibm.icu.util.MeasureUnit
-
- com.ibm.icu.util.Currency
-
- All Implemented Interfaces:
java.io.Serializable
- Direct Known Subclasses:
CustomSymbolCurrency
public class Currency extends 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
Note: This class deliberately resembles java.util.Currency but it has a completely independent implementation, and adds features not present in the JDK.
- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static class
Currency.CurrencyNameResultHandler
static class
Currency.CurrencyStringInfo
Deprecated.This API is ICU internal only.static class
Currency.CurrencyUsage
Currency Usage used for Decimal Format(package private) static class
Currency.ServiceShim
-
Nested classes/interfaces inherited from class com.ibm.icu.util.MeasureUnit
MeasureUnit.Complexity, MeasureUnit.Factory, MeasureUnit.MeasurePrefix, MeasureUnit.MeasureUnitProxy
-
-
Field Summary
Fields Modifier and Type Field Description private static java.lang.ref.SoftReference<java.util.Set<java.lang.String>>
ALL_CODES_AS_SET
private static java.lang.ref.SoftReference<java.util.List<java.lang.String>>
ALL_TENDER_CODES
private static ICUCache<ULocale,java.util.List<TextTrieMap<Currency.CurrencyStringInfo>>>
CURRENCY_NAME_CACHE
private static boolean
DEBUG
private static java.lang.String[]
EMPTY_STRING_ARRAY
static int
FORMAL_SYMBOL_NAME
Selector for getName() indicating the formal currency symbol.private java.lang.String
isoCode
ISO 4217 3-letter code.static int
LONG_NAME
Selector for getName() indicating the long name for a currency, such as "US Dollar" for USD.static int
NARROW_SYMBOL_NAME
Selector for getName() indicating the narrow currency symbol.static int
PLURAL_LONG_NAME
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".private static int[]
POW10
private static CacheBase<java.lang.String,Currency,java.lang.Void>
regionCurrencyCache
private static long
serialVersionUID
private static Currency.ServiceShim
shim
static int
SYMBOL_NAME
Selector for getName() indicating a symbolic name for a currency, such as "$" for USD.private static ULocale
UND
static int
VARIANT_SYMBOL_NAME
Selector for getName() indicating the variant currency symbol.-
Fields inherited from class com.ibm.icu.util.MeasureUnit
ACRE, ACRE_FOOT, AMPERE, ARC_MINUTE, ARC_SECOND, ASCII, ASCII_HYPHEN_DIGITS, ASTRONOMICAL_UNIT, ATMOSPHERE, BAR, BARREL, BEAUFORT, BIT, BRITISH_THERMAL_UNIT, BUSHEL, BYTE, CALORIE, CANDELA, CARAT, CELSIUS, CENTILITER, CENTIMETER, CENTURY, CUBIC_CENTIMETER, CUBIC_FOOT, CUBIC_INCH, CUBIC_KILOMETER, CUBIC_METER, CUBIC_MILE, CUBIC_YARD, CUP, CUP_METRIC, CURRENCY_FACTORY, DALTON, DAY, DAY_PERSON, DECADE, DECILITER, DECIMETER, DEGREE, DESSERT_SPOON, DESSERT_SPOON_IMPERIAL, DOT, DOT_PER_CENTIMETER, DOT_PER_INCH, DRAM, DROP, DUNAM, EARTH_MASS, EARTH_RADIUS, ELECTRONVOLT, EM, FAHRENHEIT, FATHOM, FLUID_OUNCE, FLUID_OUNCE_IMPERIAL, FOODCALORIE, FOOT, FURLONG, G_FORCE, GALLON, GALLON_IMPERIAL, GASOLINE_ENERGY_DENSITY, GENERIC_TEMPERATURE, GIGABIT, GIGABYTE, GIGAHERTZ, GIGAWATT, GRAIN, GRAM, HECTARE, HECTOLITER, HECTOPASCAL, HERTZ, HORSEPOWER, HOUR, INCH, INCH_HG, ITEM, JIGGER, JOULE, KARAT, KELVIN, KILOBIT, KILOBYTE, KILOCALORIE, KILOGRAM, KILOHERTZ, KILOJOULE, KILOMETER, KILOMETER_PER_HOUR, KILOPASCAL, KILOWATT, KILOWATT_HOUR, KILOWATT_HOUR_PER_100_KILOMETER, KNOT, 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, MILLILITER, MILLIMETER, MILLIMETER_OF_MERCURY, MILLIMOLE_PER_LITER, MILLISECOND, MILLIWATT, MINUTE, MOLE, MONTH, MONTH_PERSON, NANOMETER, NANOSECOND, NAUTICAL_MILE, NEWTON, NEWTON_METER, NIGHT, OHM, OUNCE, OUNCE_TROY, PARSEC, PART_PER_MILLION, PASCAL, PERCENT, PERMILLE, PERMYRIAD, PETABYTE, PICOMETER, PINCH, PINT, PINT_METRIC, PIXEL, PIXEL_PER_CENTIMETER, PIXEL_PER_INCH, POINT, POUND, POUND_FOOT, POUND_FORCE, POUND_PER_SQUARE_INCH, QUART, QUART_IMPERIAL, QUARTER, RADIAN, REVOLUTION_ANGLE, SECOND, SOLAR_LUMINOSITY, SOLAR_MASS, SOLAR_RADIUS, SQUARE_CENTIMETER, SQUARE_FOOT, SQUARE_INCH, SQUARE_KILOMETER, SQUARE_METER, SQUARE_MILE, SQUARE_YARD, STONE, subType, TABLESPOON, TEASPOON, TERABIT, TERABYTE, THERM_US, TIMEUNIT_FACTORY, TON, TONNE, type, VOLT, WATT, WEEK, WEEK_PERSON, YARD, YEAR, YEAR_PERSON
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
Currency(java.lang.String theISOCode)
Constructs a currency object for the given ISO 4217 3-letter code.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description (package private) static Currency
createCurrency(ULocale loc)
Instantiate a currency from resource data.static Currency
fromJavaCurrency(java.util.Currency currency)
Returns a Currency object based on the currency represented by the given java.util.Currency.private static java.util.Set<java.lang.String>
getAllCurrenciesAsSet()
private static java.util.List<java.lang.String>
getAllTenderCurrencies()
static java.util.Set<Currency>
getAvailableCurrencies()
Returns the set of available currencies.static java.lang.String[]
getAvailableCurrencyCodes(ULocale loc, java.util.Date d)
Returns an array of Strings which contain the currency identifiers that are valid for the given locale on the given date.static java.lang.String[]
getAvailableCurrencyCodes(java.util.Locale loc, java.util.Date d)
Returns an array of Strings which contain the currency identifiers that are valid for the givenLocale
on the given date.static java.util.Locale[]
getAvailableLocales()
Return an array of the locales for which a currency is defined.static ULocale[]
getAvailableULocales()
Return an array of the ulocales for which a currency is defined.java.lang.String
getCurrencyCode()
Returns the ISO 4217 3-letter code for this currency object.private static java.util.List<TextTrieMap<Currency.CurrencyStringInfo>>
getCurrencyTrieVec(ULocale locale)
int
getDefaultFractionDigits()
Returns the number of the number of fraction digits that should be displayed for this currency.int
getDefaultFractionDigits(Currency.CurrencyUsage Usage)
Returns the number of the number of fraction digits that should be displayed for this currency with Usage.java.lang.String
getDisplayName()
Returns the display name for this currency in the default locale.java.lang.String
getDisplayName(java.util.Locale locale)
Returns the display name for this currency in the given locale.static Currency
getInstance(ULocale locale)
Returns a currency object for the default currency in the given locale.static Currency
getInstance(java.lang.String theISOCode)
Returns a currency object given an ISO 4217 3-letter code.static Currency
getInstance(java.util.Locale locale)
Returns a currency object for the default currency in the given locale.static java.lang.String[]
getKeywordValuesForLocale(java.lang.String key, ULocale locale, boolean commonlyUsed)
Given a key and a locale, returns an array of values for the key for which data exists.java.lang.String
getName(ULocale locale, int nameStyle, boolean[] isChoiceFormat)
Returns the display name for the given currency in the given locale.java.lang.String
getName(ULocale locale, int nameStyle, java.lang.String pluralCount, boolean[] isChoiceFormat)
Returns the display name for the given currency in the given locale.java.lang.String
getName(java.util.Locale locale, int nameStyle, boolean[] isChoiceFormat)
Returns the display name for the given currency in the given locale.java.lang.String
getName(java.util.Locale locale, int nameStyle, java.lang.String pluralCount, boolean[] isChoiceFormat)
Returns the display name for the given currency in the given locale.int
getNumericCode()
Returns the ISO 4217 numeric code for this currency object.static TextTrieMap<Currency.CurrencyStringInfo>
getParsingTrie(ULocale locale, int type)
Deprecated.This API is ICU internal only.double
getRoundingIncrement()
Returns the rounding increment for this currency, or 0.0 if no rounding is done by this currency.double
getRoundingIncrement(Currency.CurrencyUsage Usage)
Returns the rounding increment for this currency, or 0.0 if no rounding is done by this currency with the Usage.private static Currency.ServiceShim
getShim()
java.lang.String
getSymbol()
Convenience and compatibility override of getName that requests the symbol name for the defaultDISPLAY
locale.java.lang.String
getSymbol(ULocale uloc)
Convenience and compatibility override of getName that requests the symbol name.java.lang.String
getSymbol(java.util.Locale loc)
Convenience and compatibility override of getName that requests the symbol name.private static java.util.List<java.lang.String>
getTenderCurrencies(CurrencyMetaInfo.CurrencyFilter filter)
Returns the list of remaining tender currencies after a filter is applied.private static boolean
isAlpha3Code(java.lang.String code)
static boolean
isAvailable(java.lang.String code, java.util.Date from, java.util.Date to)
Queries if the given ISO 4217 3-letter code is available on the specified date range.private static Currency
loadCurrency(java.lang.String key)
static java.lang.String
parse(ULocale locale, java.lang.String text, int type, java.text.ParsePosition pos)
Deprecated.This API is ICU internal only.private java.lang.Object
readResolve()
static java.lang.Object
registerInstance(Currency currency, ULocale locale)
Registers a new currency for the provided locale.private static void
setupCurrencyTrieVec(ULocale locale, java.util.List<TextTrieMap<Currency.CurrencyStringInfo>> trieVec)
java.util.Currency
toJavaCurrency()
Returns a java.util.Currency object based on the currency represented by this Currency.java.lang.String
toString()
Returns the ISO 4217 code for this currency.static boolean
unregister(java.lang.Object registryKey)
Unregister the currency associated with this key (obtained from registerInstance).private java.lang.Object
writeReplace()
-
Methods inherited from class com.ibm.icu.util.MeasureUnit
addUnit, equals, findBySubType, forIdentifier, fromMeasureUnitImpl, getAvailable, getAvailable, getAvailableTypes, getComplexity, getCopyOfMeasureUnitImpl, getDimensionality, getIdentifier, getPrefix, getSubtype, getType, hashCode, internalGetInstance, product, reciprocal, splitToSingleUnits, withDimensionality, withPrefix
-
-
-
-
Field Detail
-
serialVersionUID
private static final long serialVersionUID
- See Also:
- Constant Field Values
-
DEBUG
private static final boolean DEBUG
-
CURRENCY_NAME_CACHE
private static ICUCache<ULocale,java.util.List<TextTrieMap<Currency.CurrencyStringInfo>>> CURRENCY_NAME_CACHE
-
SYMBOL_NAME
public static final int SYMBOL_NAME
Selector for getName() indicating a symbolic name for a currency, such as "$" for USD.- See Also:
- Constant Field Values
-
LONG_NAME
public static final int LONG_NAME
Selector for getName() indicating the long name for a currency, such as "US Dollar" for USD.- See Also:
- Constant Field Values
-
PLURAL_LONG_NAME
public static final int PLURAL_LONG_NAME
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".- See Also:
- Constant Field Values
-
NARROW_SYMBOL_NAME
public static final int NARROW_SYMBOL_NAME
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.
- See Also:
- Constant Field Values
-
FORMAL_SYMBOL_NAME
public static final int FORMAL_SYMBOL_NAME
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.
- See Also:
- Constant Field Values
-
VARIANT_SYMBOL_NAME
public static final int VARIANT_SYMBOL_NAME
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.
- See Also:
- Constant Field Values
-
shim
private static Currency.ServiceShim shim
-
regionCurrencyCache
private static final CacheBase<java.lang.String,Currency,java.lang.Void> regionCurrencyCache
-
UND
private static final ULocale UND
-
EMPTY_STRING_ARRAY
private static final java.lang.String[] EMPTY_STRING_ARRAY
-
POW10
private static final int[] POW10
-
ALL_TENDER_CODES
private static java.lang.ref.SoftReference<java.util.List<java.lang.String>> ALL_TENDER_CODES
-
ALL_CODES_AS_SET
private static java.lang.ref.SoftReference<java.util.Set<java.lang.String>> ALL_CODES_AS_SET
-
isoCode
private final java.lang.String isoCode
ISO 4217 3-letter code.
-
-
Method Detail
-
getShim
private static Currency.ServiceShim getShim()
-
getInstance
public static Currency getInstance(java.util.Locale locale)
Returns a currency object for the default currency in the given locale.- Parameters:
locale
- the locale- Returns:
- the currency object for this locale
-
getInstance
public static Currency getInstance(ULocale locale)
Returns a currency object for the default currency in the given locale.
-
getAvailableCurrencyCodes
public static java.lang.String[] getAvailableCurrencyCodes(ULocale loc, java.util.Date d)
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.
-
getAvailableCurrencyCodes
public static java.lang.String[] getAvailableCurrencyCodes(java.util.Locale loc, java.util.Date d)
Returns an array of Strings which contain the currency identifiers that are valid for the givenLocale
on the given date. If there are no such identifiers, returns null. Returned identifiers are in preference order.- Parameters:
loc
- theLocale
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.
-
getAvailableCurrencies
public static java.util.Set<Currency> 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.
-
createCurrency
static Currency createCurrency(ULocale loc)
Instantiate a currency from resource data.
-
loadCurrency
private static Currency loadCurrency(java.lang.String key)
-
getInstance
public static Currency getInstance(java.lang.String theISOCode)
Returns a currency object given an ISO 4217 3-letter code.- Parameters:
theISOCode
- the iso code- Returns:
- the currency for this iso code
- Throws:
java.lang.NullPointerException
- iftheISOCode
is null.java.lang.IllegalArgumentException
- iftheISOCode
is not a 3-letter alpha code.
-
isAlpha3Code
private static boolean isAlpha3Code(java.lang.String code)
-
fromJavaCurrency
public static Currency fromJavaCurrency(java.util.Currency currency)
Returns a Currency object based on the currency represented by the given java.util.Currency.- Parameters:
currency
- The Java currency object to convert.- Returns:
- An equivalent ICU currency object.
-
toJavaCurrency
public java.util.Currency toJavaCurrency()
Returns a java.util.Currency object based on the currency represented by this Currency.- Returns:
- An equivalent Java currency object.
-
registerInstance
public static java.lang.Object registerInstance(Currency currency, ULocale locale)
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:
unregister(java.lang.Object)
-
unregister
public static boolean unregister(java.lang.Object registryKey)
Unregister the currency associated with this key (obtained from registerInstance).- Parameters:
registryKey
- the registry key returned from registerInstance- See Also:
registerInstance(com.ibm.icu.util.Currency, com.ibm.icu.util.ULocale)
-
getAvailableLocales
public static java.util.Locale[] getAvailableLocales()
Return an array of the locales for which a currency is defined.- Returns:
- an array of the available locales
-
getAvailableULocales
public static ULocale[] getAvailableULocales()
Return an array of the ulocales for which a currency is defined.- Returns:
- an array of the available ulocales
-
getKeywordValuesForLocale
public static final java.lang.String[] getKeywordValuesForLocale(java.lang.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.
-
getCurrencyCode
public java.lang.String getCurrencyCode()
Returns the ISO 4217 3-letter code for this currency object.
-
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.
-
getSymbol
public java.lang.String getSymbol()
Convenience and compatibility override of getName that requests the symbol name for the defaultDISPLAY
locale.
-
getSymbol
public java.lang.String getSymbol(java.util.Locale loc)
Convenience and compatibility override of getName that requests the symbol name.- Parameters:
loc
- the Locale for the symbol- See Also:
getName(java.util.Locale, int, boolean[])
-
getSymbol
public java.lang.String getSymbol(ULocale uloc)
Convenience and compatibility override of getName that requests the symbol name.- Parameters:
uloc
- the ULocale for the symbol- See Also:
getName(java.util.Locale, int, boolean[])
-
getName
public java.lang.String getName(java.util.Locale locale, int nameStyle, boolean[] isChoiceFormat)
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.
-
getName
public java.lang.String getName(ULocale locale, int nameStyle, boolean[] isChoiceFormat)
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:
java.lang.IllegalArgumentException
- if the nameStyle is not SYMBOL_NAME or LONG_NAME.- See Also:
getName(ULocale, int, String, boolean[])
-
getName
public java.lang.String getName(java.util.Locale locale, int nameStyle, java.lang.String pluralCount, boolean[] isChoiceFormat)
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.
-
getName
public java.lang.String getName(ULocale locale, int nameStyle, java.lang.String pluralCount, boolean[] isChoiceFormat)
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:
java.lang.IllegalArgumentException
- if the nameStyle is not SYMBOL_NAME, LONG_NAME, or PLURAL_LONG_NAME.
-
getDisplayName
public java.lang.String 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:
getDisplayName(Locale)
,getName(Locale, int, boolean[])
-
getDisplayName
public java.lang.String getDisplayName(java.util.Locale locale)
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:
getDisplayName(Locale)
,getName(Locale, int, boolean[])
-
parse
@Deprecated public static java.lang.String parse(ULocale locale, java.lang.String text, int type, java.text.ParsePosition pos)
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
-
getParsingTrie
@Deprecated public static TextTrieMap<Currency.CurrencyStringInfo> getParsingTrie(ULocale locale, int type)
Deprecated.This API is ICU internal only.
-
getCurrencyTrieVec
private static java.util.List<TextTrieMap<Currency.CurrencyStringInfo>> getCurrencyTrieVec(ULocale locale)
-
setupCurrencyTrieVec
private static void setupCurrencyTrieVec(ULocale locale, java.util.List<TextTrieMap<Currency.CurrencyStringInfo>> trieVec)
-
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
-
getDefaultFractionDigits
public int getDefaultFractionDigits(Currency.CurrencyUsage Usage)
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
-
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
-
getRoundingIncrement
public double getRoundingIncrement(Currency.CurrencyUsage Usage)
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
-
toString
public java.lang.String toString()
Returns the ISO 4217 code for this currency.- Overrides:
toString
in classMeasureUnit
-
getAllTenderCurrencies
private static java.util.List<java.lang.String> getAllTenderCurrencies()
-
getAllCurrenciesAsSet
private static java.util.Set<java.lang.String> getAllCurrenciesAsSet()
-
isAvailable
public static boolean isAvailable(java.lang.String code, java.util.Date from, java.util.Date to)
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
andto
. When bothfrom
andto
are 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. Whenfrom
is null, check the availability of the currency any date beforeto
to
- The upper bound of the date range, inclusive. Whento
is 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:
java.lang.IllegalArgumentException
- whento
is beforefrom
.
-
getTenderCurrencies
private static java.util.List<java.lang.String> getTenderCurrencies(CurrencyMetaInfo.CurrencyFilter filter)
Returns the list of remaining tender currencies after a filter is applied.- Parameters:
filter
- the filter to apply to the tender currencies- Returns:
- a list of tender currencies
-
writeReplace
private java.lang.Object writeReplace() throws java.io.ObjectStreamException
- Throws:
java.io.ObjectStreamException
-
readResolve
private java.lang.Object readResolve() throws java.io.ObjectStreamException
- Throws:
java.io.ObjectStreamException
-
-