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

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

问题来了:为什么这样:

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

打印 "EUR 1E+2",但任何其他小数 != .00 将打印正确:

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

"EUR 100.01"???

好的,

看起来 MonetaryAmount 调用了 toString(),它将调用 BigDecimalengineeringString。打印 MonetaryAmount 的正确方法是格式化它:

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