public final class

Currency

extends Object
implements Serializable
java.lang.Object
   ↳ java.util.Currency

Class Overview

This class represents a currency as identified in the ISO 4217 currency codes.

Summary

Public Methods
String getCurrencyCode()
Returns this Currency's ISO 4217 currency code.
int getDefaultFractionDigits()
Returns the default number of fraction digits for this currency.
static Currency getInstance(Locale locale)
Returns the Currency instance for this Locale's country.
static Currency getInstance(String currencyCode)
Returns the Currency instance for this currency code.
String getSymbol()
Returns the symbol for this currency in the default locale.
String getSymbol(Locale locale)
Returns the symbol for this currency in the given Locale.
String toString()
Returns this currency's ISO 4217 currency code.
[Expand]
Inherited Methods
From class java.lang.Object

Public Methods

public String getCurrencyCode ()

Since: API Level 1

Returns this Currency's ISO 4217 currency code.

Returns
  • this Currency's ISO 4217 currency code.

public int getDefaultFractionDigits ()

Since: API Level 1

Returns the default number of fraction digits for this currency. For instance, the default number of fraction digits for the US dollar is 2. For the Japanese Yen the number is 0. In the case of pseudo-currencies, such as IMF Special Drawing Rights, -1 is returned.

Returns
  • the default number of fraction digits for this currency.

public static Currency getInstance (Locale locale)

Since: API Level 1

Returns the Currency instance for this Locale's country.

Parameters
locale the Locale of a country.
Returns
  • the Currency used in the country defined by the locale parameter.
Throws
IllegalArgumentException if the locale's country is not a supported ISO 3166 Country.

public static Currency getInstance (String currencyCode)

Since: API Level 1

Returns the Currency instance for this currency code.

Parameters
currencyCode the currency code.
Returns
  • the Currency instance for this currency code.
Throws
IllegalArgumentException if the currency code is not a supported ISO 4217 currency code.

public String getSymbol ()

Since: API Level 1

Returns the symbol for this currency in the default locale. For instance, if the default locale is the US, the symbol of the US dollar is "$". For other locales it may be "US$". If no symbol can be determined, the ISO 4217 currency code of the US dollar is returned.

Returns
  • the symbol for this Currency in the default Locale.

public String getSymbol (Locale locale)

Since: API Level 1

Returns the symbol for this currency in the given Locale.

If the locale doesn't have any countries (e.g. Locale.JAPANESE, new Locale("en","")), the the ISO 4217 currency code is returned.

First the locale's resource bundle is checked, if the locale has the same currency, the CurrencySymbol in this locale bundle is returned.

Then a currency bundle for this locale is searched.

If a currency bundle for this locale does not exist, or there is no symbol for this currency in this bundle, then the ISO 4217 currency code is returned.

Parameters
locale the locale for which the currency symbol should be returned.
Returns
  • the representation of this Currency's symbol in the specified locale.

public String toString ()

Since: API Level 1

Returns this currency's ISO 4217 currency code.

Returns
  • this currency's ISO 4217 currency code.