Top Description Methods
javax.money

public Interface CurrencyUnit

extends Comparable<CurrencyUnit>

A unit of currency.

This interface represents a unit of currency such as the British Pound, Euro, US Dollar, Bitcoin or other. It provides interoperability between different implementations.

Currencies can be distinguished by separate getCurrencyCode() codes, similar to java.util.Currency.

Implementation specification

Implementation of this class
Authors
Werner Keil, Stephen Colebourne, Anatole Tresch
Version
1.0
See Also
Wikipedia: Currency

Method Summary

Modifier and TypeMethod and Description
public CurrencyContext

Returns:

the currency's context, never null.
getContext
()

Returns the javax.money.CurrencyContext of a currency.

public String

Returns:

the currency code, never null. For ISO-4217 this this will be the three letter ISO-4217 code. However, alternate currencies can have different codes. Also there is no constraint about the formatting of alternate codes, despite the fact that the currency codes must be unique.
getCurrencyCode
()

Gets the unique currency code, the effective code depends on the currency.

public int

Returns:

the fractional digits, from 0 to 9 (normally 0, 2 or 3), or 0 for pseudo-currencies.
getDefaultFractionDigits
()

Gets the number of fractional digits typically used by this currency.

public int

Returns:

the numeric currency code
getNumericCode
()

Gets a numeric currency code.

Inherited from java.lang.Comparable:
compareTo

Method Detail

getContextback to summary
public CurrencyContext getContext()

Returns the javax.money.CurrencyContext of a currency. This context contains additional information about the type and capabilities of a CurrencyUnit, e.g. its provider and more.

Returns:CurrencyContext

the currency's context, never null.

getCurrencyCodeback to summary
public String getCurrencyCode()

Gets the unique currency code, the effective code depends on the currency.

Since each currency is identified by this code, the currency code is required to be defined for every CurrencyUnit and not null or empty.

For ISO codes the 3-letter ISO code should be returned. For non ISO currencies no constraints are defined.

Returns:String

the currency code, never null. For ISO-4217 this this will be the three letter ISO-4217 code. However, alternate currencies can have different codes. Also there is no constraint about the formatting of alternate codes, despite the fact that the currency codes must be unique.

getDefaultFractionDigitsback to summary
public int getDefaultFractionDigits()

Gets the number of fractional digits typically used by this currency.

Different currencies have different numbers of fractional digits by default. For example, 'GBP' has 2 fractional digits, but 'JPY' has zero. virtual currencies or those with no applicable fractional are indicated by -1.

This method matches the API of java.util.Currency.

Returns:int

the fractional digits, from 0 to 9 (normally 0, 2 or 3), or 0 for pseudo-currencies.

getNumericCodeback to summary
public int getNumericCode()

Gets a numeric currency code. within the ISO-4217 name space, this equals to the ISO numeric code. In other currency name spaces this number may be different, or even undefined (-1).

The numeric code is an optional alternative to the standard currency code. If defined, the numeric code is required to be unique.

This method matches the API of java.util.Currency.

Returns:int

the numeric currency code