Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

java decimal separator

Is there a way to configure Java's decimal separators with JVM parameters? I'd know how to do it in code level, but unfortunately this time I cannot touch it.

I have now: "1,322.03" and I wish there was some config that would make that look like 1.322,03.

Oracle has that NLS_NUMERIC_CHARACTERS, which solve's for me in most cases, but I've got lost in this one.

thanks.

f.

like image 434
filippo Avatar asked Jun 14 '26 13:06

filippo


1 Answers

Your output looks like this used DecimalFormat, in a locale-dependent way (like NumberFormat.getInstance().format(value) or similar).

If this is the case, then simply setting the default Locale to another locale which has the inverse formatting rules should do. Sadly this will also affect every other use of the locale, not only numbers. Java does not support different locales for different uses (like the GNU system).

Try -Duser.language=de -Duser.country=DE to get german-like number output. (I suppose one of them will be enough, but I didn't test this.) Of course, you can use other locales with this number setting as well.

like image 138
Paŭlo Ebermann Avatar answered Jun 16 '26 07:06

Paŭlo Ebermann



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!