public final class ConversionOperators extends Object
The class is thread-safe, which is also true for all functions returned by this class.
MonetaryAmount money = Money.parse("EUR 2.35");
MonetaryAmount result = operator.apply(money);
Or using:
MonetaryAmount money = Money.parse("EUR 2.35");
MonetaryAmount result = money.with(operator);
MonetaryAmount#with(MonetaryOperator)},
MonetaryOperator},
MonetaryOperator#apply(MonetaryAmount)}| Modifier and Type | Method and Description |
|---|---|
static javax.money.MonetaryOperator |
exchange(javax.money.CurrencyUnit currencyUnit)
Do exchange of currency, in other words, create the monetary amount with the
same value but with currency different.
|
static java.util.stream.Collector<javax.money.MonetaryAmount,MonetarySummaryStatistics,MonetarySummaryStatistics> |
summarizingMonetary(javax.money.CurrencyUnit currencyUnit,
javax.money.convert.ExchangeRateProvider provider)
of the summary of the MonetaryAmount
|
public static javax.money.MonetaryOperator exchange(javax.money.CurrencyUnit currencyUnit)
For example, 'EUR 2.35', using the currency 'USD' as exchange parameter, will return 'USD 2.35', and 'BHD -1.345', using the currency 'USD' as exchange parameter, will return 'BHD -1.345'.
Currency real = Monetary.getCurrency("BRL");
MonetaryAmount money = Money.parse("EUR 2.355");
MonetaryAmount result = ConversionOperators.exchangeCurrency(real).apply(money);//BRL 2.355
roundingMode - rounding to be usedMonetaryOperatorpublic static java.util.stream.Collector<javax.money.MonetaryAmount,MonetarySummaryStatistics,MonetarySummaryStatistics> summarizingMonetary(javax.money.CurrencyUnit currencyUnit, javax.money.convert.ExchangeRateProvider provider)
currencyUnit - the target CurrencyUnitCopyright © 2012-2016 JavaMoney. All Rights Reserved.