Petar Tahchiev
Petar Tahchiev

Reputation: 4386

Monetary.of(new BigDecimal("100.00"), "EUR") prints "EUR 1E+2"

So here's the question: why this:

Monetary.of(new BigDecimal("100.00"), "EUR") 

prints "EUR 1E+2", but any other decimal != .00 will print correct:

Monetary.of(new BigDecimal("100.01"), "EUR") 

"EUR 100.01"???

Upvotes: 1

Views: 333

Answers (1)

Petar Tahchiev
Petar Tahchiev

Reputation: 4386

OK,

it looks like the MonetaryAmount calls toString() which will call the engineeringString of the BigDecimal. The correct way to print a MonetaryAmount is to format it:

MonetaryFormats.getAmountFormat(Locale.getDefault()).format(Money.of(source.getValue(), source.getCurrency().getUid()))

Upvotes: 1

Related Questions