Name

Currency

Synopsis

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.

java.util.Currency

Figure 16-12. java.util.Currency

public final class Currency implements Serializable {
// No Constructor
                  // Public Class Methods public static Currency ...

Get Java in a Nutshell, 5th Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.