I am using org.javamoney.moneta library to perform some currency conversion. After the conversion, I got a number with very long digits after the comma, something like 1234.0000000000000. I would like to have only two digits after the comma. Can anyone give me some idea how to archive this?
Here is my code:
MonetaryAmount sourceAmount= Monetary.getDefaultAmountFactory().setCurrency("USD")
.setNumber(1234.0).create();
CurrencyConversion targetConversion = MonetaryConversions.getConversion("EUR");
MonetaryAmount targetAmount = source.with(targetConversion);
System.out.println(targetAmout.toString());