Package org.javamoney.moneta.convert
Class ConversionOperators
java.lang.Object
org.javamoney.moneta.convert.ConversionOperators
This singleton class provides access to the predefined monetary functions.
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);
- Since:
- 1.0.1
- Author:
- Werner Keil
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionstatic MonetaryOperatorexchange(CurrencyUnit currencyUnit) Do exchange of currency, in other words, create the monetary amount with the same value but with currency different.summarizingMonetary(CurrencyUnit currencyUnit, ExchangeRateProvider provider) of the summary of the MonetaryAmount
-
Method Details
-
exchange
Do exchange of currency, in other words, create the monetary amount with the same value but with currency different.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- Parameters:
currencyUnit- the currency to be used- Returns:
- the major part as
MonetaryOperator - Since:
- 1.0.1
-
summarizingMonetary
public static Collector<MonetaryAmount,MonetarySummaryStatistics, summarizingMonetaryMonetarySummaryStatistics> (CurrencyUnit currencyUnit, ExchangeRateProvider provider) of the summary of the MonetaryAmount- Parameters:
currencyUnit- the targetCurrencyUnit- Returns:
- the MonetarySummaryStatistics
-