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

It's unclear what's intended in CurrencyFormat of cli #7383

Open
thecockatiel opened this issue Feb 5, 2025 · 0 comments
Open

It's unclear what's intended in CurrencyFormat of cli #7383

thecockatiel opened this issue Feb 5, 2025 · 0 comments

Comments

@thecockatiel
Copy link
Contributor

// Use the US locale as a base for all DecimalFormats, but commas should be omitted from number strings.
private static final DecimalFormatSymbols DECIMAL_FORMAT_SYMBOLS = DecimalFormatSymbols.getInstance(Locale.US);
// Use the US locale as a base for all NumberFormats, but commas should be omitted from number strings.
private static final NumberFormat US_LOCALE_NUMBER_FORMAT = NumberFormat.getInstance(Locale.US);

In comment of both DECIMAL_FORMAT_SYMBOLS and US_LOCALE_NUMBER_FORMAT it is mentioned that commas should be omitted from number strings, but US_LOCALE_NUMBER_FORMAT produces strings that include comma

is this intended ? if so the comment needs to be updated
if not, then the formatting is producing incorrect results

also rounding mode in formatPrice is a bit vague:

US_LOCALE_NUMBER_FORMAT.setRoundingMode(UNNECESSARY);

was the intention to simply truncate the price and not round it ? because java docs show that UNNECESSARY rounding throws ArithmeticException in many cases:
https://docs.oracle.com/javase/8/docs/api/java/math/RoundingMode.html

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

No branches or pull requests

1 participant