Build 1.0_r1(from source)

java.util
Class Currency

java.lang.Object
  extended by java.util.Currency
All Implemented Interfaces:
Serializable

public final class Currency
extends Object
implements Serializable

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

See Also:
Serialized Form

Method Summary
 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.
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)
          Return the symbol for this currency in the given locale.
 String toString()
          Returns this currency's ISO 4217 currency code.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Method Detail

getInstance

public static Currency getInstance(String currencyCode)
Returns the currency instance for this currency code.

Parameters:
currencyCode - java.lang.String
Returns:
currency java.util.Currency
Throws:
IllegalArgumentException - if the currency code is not a supported ISO 4217 currency code

getInstance

public static Currency getInstance(Locale locale)
Returns the currency instance for this locale.

Parameters:
locale - java.util.Locale
Returns:
currency java.util.Currency
Throws:
IllegalArgumentException - if the locale's country is not a supported ISO 3166 Country

getCurrencyCode

public String getCurrencyCode()
Returns this currency's ISO 4217 currency code.

Returns:
this currency's ISO 4217 currency code

getSymbol

public String getSymbol()
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

getSymbol

public String getSymbol(Locale locale)
Return the symbol for this currency in the given locale.

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

First the locale 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, than currencyCode is returned.

Parameters:
locale - java.lang.String locale
Returns:
symbol java.lang.String the representation of this Currency's symbol in this locale

getDefaultFractionDigits

public int getDefaultFractionDigits()
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

toString

public String toString()
Returns this currency's ISO 4217 currency code.

Overrides:
toString in class Object
Returns:
this currency's ISO 4217 currency code

Build 1.0_r1(from source)

Please submit a feedback, bug or feature