0

When I upgrade my application server from tomcat 7 to 9, default decimal format is changed.

For example,

new DecimalFormat(".##").format(111.111)

Its result in tomcat 7 is "111.11" but in tomcat 9 result is "111,11"

I can accomplish the problem adding locale setting in code like below

Locale locale=new Locale("en","US");
String pattern=".##";
DecimalFormat decimalFormat=(DecimalFormat) NumberFormat.getNumberInstance(locale);
decimalFormat.applyPattern(pattern);

But how can I accomplish decimal format locale settings without changing the application code? Is there a way to change locale from tomcat or something else?

  • 1
    Does this answer your question? [How do I set the default locale in the JVM?](https://stackoverflow.com/questions/8809098/how-do-i-set-the-default-locale-in-the-jvm) – Piotr P. Karwasz Sep 03 '21 at 09:15
  • Tomcat does not change the default locale. My guess you try to change it in your code by setting the `user.language` system property, which works only until the first usage of the `Locale` class. – Piotr P. Karwasz Sep 03 '21 at 09:50

0 Answers0