Team LiB
Previous Section Next Section

Currencyjava.util

Java 1.4serializable

Instances of this class represent a currency. Obtain a Currency object by passing a "currency code" such as "USD" for U.S. Dollars or "EUR" for Euros to getInstance( ). Once you have a Currency object, use getSymbol( ) to obtain the currency symbol (which is often different from the currency code) for the default locale or for a specified Locale. The symbol for a USD would be "$" in a U.S locale, but might be "US$" in other locales, for example. If no symbol is known, this method returns the currency code.

Use geTDefaultFractionDigits( ) to determine how many fractional digits are conventionally used with the currency. This method returns 2 for the U.S. Dollar and other currencies that are divided into hundredths, but returns 3 for the Jordanian Dinar (JOD) and other currencies which are traditionally divided into thousandths, and returns 0 for the Japanese Yen (JPY) and other currencies that have a small unit value and are not usually divided into fractional parts at all. Currency codes are standardized by the ISO 4217 standard. For a complete list of currencies and currency codes see the website of the "maintenance agency" for this standard: http://www.iso.org/iso/en/prods-services/popstds/currencycodeslist.html.

Figure 16-12. java.util.Currency


public final class Currency implements Serializable {
// No Constructor
// Public Class Methods
     public static Currency getInstance(String currencyCode);  
     public static Currency getInstance(Locale locale);  
// Public Instance Methods
     public String getCurrencyCode( );  
     public int getDefaultFractionDigits( );  
     public String getSymbol( );  
     public String getSymbol(Locale locale);  
// Public Methods Overriding Object
     public String toString( );  
}

Passed To

java.text.DecimalFormat.setCurrency( ), java.text.DecimalFormatSymbols.setCurrency( ), java.text.NumberFormat.setCurrency( )

Returned By

java.text.DecimalFormat.getCurrency( ), java.text.DecimalFormatSymbols.getCurrency( ), java.text.NumberFormat.getCurrency( )

    Team LiB
    Previous Section Next Section