|
JADE v6.1 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjavax.units.Unit
javax.units.BaseUnit
com.dautelle.money.Currency
This class represents a currency Unit
.
Currencies are BaseUnit
, conversions between currencies is
possible if their respective exchange rates have been set.
Quantities stated in Currency
are instances of Money
.
By default, the label associated to a currency is its ISO-4217 code
(see the ISO 4217
maintenance agency for a table of currency codes). An application may
change this default using the UnitFormat.label(...)
static method.
For example:
UnitFormat.label(Currency.EUR, "€"); UnitFormat.label(Currency.GBP, "£"); UnitFormat.label(Currency.JPY, "¥"); UnitFormat.label(Currency.USD, "$");
setExchangeRate(double)
,
Serialized FormField Summary | |
static Currency |
AUD
The Australian Dollar currency unit. |
static Currency |
CAD
The Canadian Dollar currency unit. |
static Currency |
CNY
The China Yan currency. |
static Currency |
EUR
The Euro currency. |
static Currency |
GBP
The British Pound currency. |
static Currency |
JPY
The Japanese Yen currency. |
static Currency |
KRW
The Korean Republic Won currency. |
static Currency |
SYSTEM
A generic currency (currency sign "¤"), used when the locale currency is unknown. |
static Currency |
TWD
The Taiwanese dollar currency. |
static Currency |
USD
The United State dollar currency. |
Fields inherited from class javax.units.Unit |
ONE |
Method Summary | |
static int |
getDefaultFractionDigits(Currency currency)
Returns the default number of fraction digits used with the specified currency unit. |
double |
getExchangeRate()
Returns the exchange rate for this Currency . |
static Currency |
getInstance(java.util.Locale locale)
Returns the currency unit for the country of the given locale. |
static BaseUnit |
getInstance(java.lang.String code)
Returns the currency unit for the given currency code. |
static Currency |
getReferenceCurrency()
Returns the currency used as reference when setting the exchange rate. |
void |
setExchangeRate(double refAmount)
Sets the exchange rate of this Currency relatively to
the reference currency. |
static void |
setReferenceCurrency(Currency currency)
Sets the reference currency (context sensitive). |
Methods inherited from class javax.units.BaseUnit |
equals, getSymbol, getSystemUnit, setDimension |
Methods inherited from class javax.units.Unit |
add, alternate, appendTo, divide, getConverterTo, getDimension, getInstance, getInstances, hashCode, isCompatible, isSystemUnit, multiply, multiply, pow, readResolve, root, searchSymbol, toString, valueOf |
Methods inherited from class java.lang.Object |
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
public static final Currency SYSTEM
public static final Currency AUD
public static final Currency CAD
public static final Currency CNY
public static final Currency EUR
public static final Currency GBP
public static final Currency JPY
public static final Currency KRW
public static final Currency TWD
public static final Currency USD
Method Detail |
public static void setReferenceCurrency(Currency currency)
currency
- the new reference currency.LocalContext
public static Currency getReferenceCurrency()
setExchangeRate(double)
,
getInstance(Locale)
public void setExchangeRate(double refAmount)
Currency
relatively to
the reference currency. Setting the exchange rate allows
for conversion between Money
stated in different currencies.
For example:Currency.setReferenceCurrency(Currency.USD); Currency.EUR.setExchangeRate(1.17); // 1.0 € = 1.17 $
refAmount
- the amount stated in the getReferenceCurrency()
equals to one unit of this Currency
.getReferenceCurrency()
public double getExchangeRate()
Currency
.
getReferenceCurrency()
equals to one unit of this Currency
.
ConversionException
- if the exchange rate has not be set for
this Currency
.public static BaseUnit getInstance(java.lang.String code)
code
- the ISO-4217 code of the currency (e.g.
"EUR", "USD", "JPY"
).
java.lang.IllegalArgumentException
- if the specified code is not an ISO-4217
code.public static Currency getInstance(java.util.Locale locale)
locale
- the locale for whose country a currency unit is returned.
SYSTEM
if unknown..public static int getDefaultFractionDigits(Currency currency)
EUR
is 2, while for the JPY
(Yen)
it's 0.
currency
- the currency unit for which the return the default
number of fraction digits is returned.
|
JADE v6.1 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |