Class ConversionOperators

java.lang.Object
org.javamoney.moneta.convert.ConversionOperators

public final class ConversionOperators
extends Object
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:
MonetaryAmount.with(MonetaryOperator), MonetaryOperator, MonetaryOperator.apply(MonetaryAmount)
  • Method Details

    • exchange

      public 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.

      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<javax.money.MonetaryAmount,​MonetarySummaryStatistics,​MonetarySummaryStatistics> summarizingMonetary​(javax.money.CurrencyUnit currencyUnit, javax.money.convert.ExchangeRateProvider provider)
      of the summary of the MonetaryAmount
      Parameters:
      currencyUnit - the target CurrencyUnit
      Returns:
      the MonetarySummaryStatistics