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

Locale formatting displaying incorrect decimal digits based on locale #358

Open
waggyza opened this issue May 28, 2021 · 3 comments
Open
Labels

Comments

@waggyza
Copy link

waggyza commented May 28, 2021

If I create a currency with 2 decimal places and then try format it in a locale with a country with no decimal places (eg. JAPAN), the USD amount gets displayed with no decimal digits.

Correct me if I am wrong but the locale in MonetaryAmountFormat using AmountFormatQueryBuilder is the locale in which we are displaying the MonetaryAmount and not necessarily the locale of the currency amount.

eg. of issue
MonetaryAmount moneyAmount = Money.of(10.32, "USD");
MonetaryAmountFormat formatter = MonetaryFormats.getAmountFormat(
AmountFormatQueryBuilder.of(Locale.JAPAN)
.set(CurrencyStyle.SYMBOL)
.build());
String testFormat = formatter.format(moneyAmount);

testFormat in this example would be shown as $10
What I am expecting is $10.32

Same is true the other way around.
MonetaryAmount moneyAmount = Money.of(10, "JPY");
MonetaryAmountFormat formatter = MonetaryFormats.getAmountFormat(
AmountFormatQueryBuilder.of(Locale.US)
.set(CurrencyStyle.SYMBOL)
.build());
String testFormat = formatter.format(moneyAmount);

testFormat is ¥10.00
What I am expecting is ¥10

@keilw
Copy link
Member

keilw commented May 28, 2021

We'll try to replicate that.
What is the version of Moneta you are using?

@keilw keilw added the analysis label May 28, 2021
@waggyza
Copy link
Author

waggyza commented May 29, 2021

Moneta version 1.4.2

org.javamoney
moneta
1.4.2
pom

@pgr0ss
Copy link

pgr0ss commented Feb 14, 2022

I'm seeing the same behavior. Has there been any update on this issue? Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants