public interface CurrencyUnit extends Comparable<CurrencyUnit>
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 Currency
.
equals/hashCode
considering the
concrete implementation type and currency code.
Modifier and Type | Method and Description |
---|---|
CurrencyContext |
getContext()
Returns the
CurrencyContext of a currency. |
String |
getCurrencyCode()
Gets the unique currency code, the effective code depends on the
currency.
|
int |
getDefaultFractionDigits()
Gets the number of fractional digits typically used by this currency.
|
int |
getNumericCode()
Gets a numeric currency code.
|
compareTo
String getCurrencyCode()
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.
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.int getNumericCode()
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 Currency
.
int getDefaultFractionDigits()
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 Currency
.
CurrencyContext getContext()
CurrencyContext
of a currency. This context contains additional information
about the type and capabilities of a CurrencyUnit, e.g. its provider and more.Copyright © 2012–2016 JSR 354 - Expert Group. All rights reserved.