filippo
filippo

Reputation: 5793

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.

Upvotes: 3

Views: 1950

Answers (1)

Paŭlo Ebermann
Paŭlo Ebermann

Reputation: 74790

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.

Upvotes: 1

Related Questions