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

StringUtils format bug on non-US system #5139

Closed
IAISI opened this issue Jan 15, 2025 · 2 comments
Closed

StringUtils format bug on non-US system #5139

IAISI opened this issue Jan 15, 2025 · 2 comments

Comments

@IAISI
Copy link
Contributor

IAISI commented Jan 15, 2025

On systems with non-US locales tests for StringUtils would fail (, and . would be swapped), as result tests would fail too.

I think the issue could be fixed by changing

    protected static final DecimalFormat shortDecimal = new DecimalFormat("##0.0");

to

    protected static final DecimalFormat shortDecimal = new DecimalFormat("##0.0", DecimalFormatSymbols.getInstance(Locale.ENGLISH));
@ItzExotical
Copy link

Can repro.
[ERROR] Failures: [ERROR] StringUtilsTest.testTicksToSeconds_FractionalTicks:91 expected: <1.5> but was: <1,5> [ERROR] StringUtilsTest.testTicksToSeconds_NegativeTicks:99 expected: <-1.0> but was: <-1,0> [ERROR] StringUtilsTest.testTicksToSeconds_PositiveTicks:81 expected: <1.5> but was: <1,5> [ERROR] StringUtilsTest.testTicksToSeconds_ZeroTicks:86 expected: <0.0> but was: <0,0> [INFO] [ERROR] Tests run: 160, Failures: 4, Errors: 0, Skipped: 0

@ItzExotical
Copy link

On systems with non-US locales tests for StringUtils would fail (, and . would be swapped), as result tests would fail too.

I think the issue could be fixed by changing

    protected static final DecimalFormat shortDecimal = new DecimalFormat("##0.0");

to

    protected static final DecimalFormat shortDecimal = new DecimalFormat("##0.0", DecimalFormatSymbols.getInstance(Locale.ENGLISH));

That fixed it. I also added:
import java.text.DecimalFormatSymbols;
Above the DecimalFormat import.

@nossr50 nossr50 closed this as completed Jan 26, 2025
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

3 participants