Incorrect formatting for currencies with 0 decimal digits
OwensCode opened this issue · 6 comments
Am I doing something wrong or is this a bug, looking at the formatting that occurs at the end of the code below? It looks like the original double value is being repeated after the formatted value in the resulting string. I have the same problem in Chile, which makes me think it may be a general problem with currencies that should be formatted with 0 decimals. Thanks for any insight you can provide!
@Test
public void testJodaJapan() {
CurrencyUnit currency = CurrencyUnit.JPY;
Money money = Money.of(currency, 12.134d, RoundingMode.HALF_EVEN);
assertEquals(Double.valueOf(12), Double.valueOf(money.getAmount().doubleValue()));
MoneyAmountStyle style = MoneyAmountStyle.LOCALIZED_GROUPING;
MoneyFormatter formatter = new MoneyFormatterBuilder().appendAmount(style).toFormatter()
.withLocale(Locale.JAPAN);
// BUG Passes - obviously wrong
assertEquals("1212", formatter.print(money));
// BUG Fails where it should succeed
assertEquals("12", formatter.print(money));
}
Looks wrong to me. I'd suggest taking a look at the source code and seeing what you find ;-)
Thanks. I had taken a quick look but didn't want to waste time on something that could be face-palm incorrect usage. I'll obviously do something more proactive if I find the issue.
@OwensCode which version are u using?
I forked the repo, set up my environment with the latest development version and seems to be working as expected (that means, the formatting it's done correctly, with 0 decimals).
Perhaps you are blocking with a situation similar to me, which is: The bug it is present on the version 0.9.1, but solved on the master branch. We only need a newer release :)
Thanks
@facundofarias I had that issue with 0.9.1.
@OwensCode can you try with the latest development version?
Thanks 👍
Duplicate of #43