class CurrencyValue
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
private long |
amount |
private java.lang.String |
currencyCode |
Constructor and Description |
---|
CurrencyValue(long amount,
java.lang.String currencyCode)
Constructs a new currency value.
|
Modifier and Type | Method and Description |
---|---|
static long |
convertAmount(double exchangeRate,
int sourceFractionDigits,
long sourceAmount,
int targetFractionDigits)
Performs a currency conversion & unit conversion.
|
static long |
convertAmount(double exchangeRate,
java.lang.String sourceCurrencyCode,
long sourceAmount,
java.lang.String targetCurrencyCode)
Performs a currency conversion & unit conversion.
|
static long |
convertAmount(ExchangeRateProvider exchangeRates,
java.lang.String sourceCurrencyCode,
long sourceAmount,
java.lang.String targetCurrencyCode)
Performs a currency conversion & unit conversion.
|
CurrencyValue |
convertTo(ExchangeRateProvider exchangeRates,
java.lang.String targetCurrencyCode)
Returns a new CurrencyValue that is the conversion of this CurrencyValue to the specified currency.
|
long |
getAmount()
The amount of the CurrencyValue.
|
java.lang.String |
getCurrencyCode()
The ISO currency code of the CurrencyValue.
|
static CurrencyValue |
parse(java.lang.String externalVal,
java.lang.String defaultCurrency)
Constructs a new currency value by parsing the specific input.
|
java.lang.String |
toString() |
public CurrencyValue(long amount, java.lang.String currencyCode)
amount
- The amount.currencyCode
- The currency code.public static CurrencyValue parse(java.lang.String externalVal, java.lang.String defaultCurrency)
externalVal
- The value to parse.defaultCurrency
- The default currency.public long getAmount()
public java.lang.String getCurrencyCode()
public static long convertAmount(ExchangeRateProvider exchangeRates, java.lang.String sourceCurrencyCode, long sourceAmount, java.lang.String targetCurrencyCode)
exchangeRates
- Exchange rates to apply.sourceCurrencyCode
- The source currency code.sourceAmount
- The source amount.targetCurrencyCode
- The target currency code.public static long convertAmount(double exchangeRate, int sourceFractionDigits, long sourceAmount, int targetFractionDigits)
exchangeRate
- Exchange rate to apply.sourceFractionDigits
- The fraction digits of the source.sourceAmount
- The source amount.targetFractionDigits
- The fraction digits of the target.public static long convertAmount(double exchangeRate, java.lang.String sourceCurrencyCode, long sourceAmount, java.lang.String targetCurrencyCode)
exchangeRate
- Exchange rate to apply.sourceCurrencyCode
- The source currency code.sourceAmount
- The source amount.targetCurrencyCode
- The target currency code.public CurrencyValue convertTo(ExchangeRateProvider exchangeRates, java.lang.String targetCurrencyCode)
exchangeRates
- The exchange rate provider.targetCurrencyCode
- The target currency code to convert this CurrencyValue to.public java.lang.String toString()
toString
in class java.lang.Object