public final class Currency extends Object implements Serializable
| Modifier and Type | Method and Description |
|---|---|
static Set<Currency> |
getAvailableCurrencies()
Returns a set of all known currencies.
|
String |
getCurrencyCode()
Returns this currency's ISO 4217 currency code.
|
int |
getDefaultFractionDigits()
Returns the default number of fraction digits for this currency.
|
String |
getDisplayName()
Equivalent to
getDisplayName(Locale.getDefault()). |
String |
getDisplayName(Locale locale)
Returns the localized name of this currency in the given
locale. |
static Currency |
getInstance(Locale locale)
Returns the
Currency instance for this Locale's country. |
static Currency |
getInstance(String currencyCode)
Returns the
Currency instance for the given ISO 4217 currency code. |
String |
getSymbol()
Equivalent to
getSymbol(Locale.getDefault()). |
String |
getSymbol(Locale locale)
Returns the localized currency symbol for this currency in
locale. |
String |
toString()
Returns this currency's ISO 4217 currency code.
|
public static Currency getInstance(String currencyCode)
Currency instance for the given ISO 4217 currency code.IllegalArgumentException - if the currency code is not a supported ISO 4217 currency code.public static Currency getInstance(Locale locale)
Currency instance for this Locale's country.IllegalArgumentException - if the locale's country is not a supported ISO 3166 country.public static Set<Currency> getAvailableCurrencies()
public String getCurrencyCode()
public String getDisplayName()
getDisplayName(Locale.getDefault()).
See "Be wary of the default locale".public String getDisplayName(Locale locale)
locale.
Returns the ISO 4217 currency code if no localized name is available.public String getSymbol()
getSymbol(Locale.getDefault()).
See "Be wary of the default locale".public String getSymbol(Locale locale)
locale.
That is, given "USD" and Locale.US, you'd get "$", but given "USD" and a non-US locale,
you'd get "US$".
If the locale only specifies a language rather than a language and a country (such as
Locale.JAPANESE or {new Locale("en", "")} rather than Locale.JAPAN or
{new Locale("en", "US")}), the ISO 4217 currency code is returned.
If there is no locale-specific currency symbol, the ISO 4217 currency code is returned.
public int getDefaultFractionDigits()