Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect formatting for currencies with 0 decimal digits #49

Closed
OwensCode opened this issue Oct 27, 2014 · 6 comments
Closed

Incorrect formatting for currencies with 0 decimal digits #49

OwensCode opened this issue Oct 27, 2014 · 6 comments

Comments

@OwensCode
Copy link

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));
}
@jodastephen
Copy link
Member

Looks wrong to me. I'd suggest taking a look at the source code and seeing what you find ;-)

@OwensCode
Copy link
Author

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.

@facundofarias
Copy link

@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).

fe5e9cfa-65c4-11e4-9f99-b3e8cd15716a

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

@OwensCode
Copy link
Author

@facundofarias I had that issue with 0.9.1.

@facundofarias
Copy link

@OwensCode can you try with the latest development version?
Thanks 👍

jodastephen added a commit that referenced this issue Nov 7, 2014
@jodastephen
Copy link
Member

Duplicate of #43

jodastephen added a commit that referenced this issue Nov 7, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

3 participants