I tried to convert a currency using the following piece of code:
final MonetaryAmount inEuro = Money.of(10, "EUR");
final ExchangeRateProvider rateProvider = MonetaryConversions.getExchangeRateProvider("ECB");
final CurrencyConversion dollarConversion = rateProvider.getCurrencyConversion("USD");
final MonetaryAmount inDollar = inEuro.with(dollarConversion);
System.out.println(String.format("%s: %s ≙ %s", rateProvider, inEuro, inDollar));
The result was the following exception:
Exception in thread "main" CurrencyConversionException [base=EUR, term=null, conversionContext=null]: Cannot convert EUR into null
at org.javamoney.moneta.spi.AbstractCurrencyConversion.apply(AbstractCurrencyConversion.java:109)
at org.javamoney.moneta.Money.with(Money.java:377)
at org.javamoney.moneta.Money.with(Money.java:58)
at CurrencyConversionDemo.main(CurrencyConversionDemo.java:34)
See #JavaMoney/jsr354-ri/161 :
I tried to convert a currency using the following piece of code:
The result was the following exception:
From my point of view this code should work.