DecimalFormat does not work properly after updating Windows

Until recently, my code worked fine on my development machine, as well as on the deployment server.

Now in blue, DecimalFormat does not work as expected, and I'm sure after Windows 10 Creators Update .

My code is:

double x = 22.44;
DecimalFormat df = new DecimalFormat("0.00");
System.out.println(df.format(x));

Exit: 22.44 Instead of 22.44

If I change it to:

double x = 22.44;
DecimalFormat df = new DecimalFormat("0,00");
System.out.println(df.format(x));

Output: 0.22

I am using netbeans 7.4 with jdk 1.7.0_79u (64 bit) I tried changing my jdk to 1.7.0_80u (32 bit) but it didn't make any difference. The locale setting for the Decimal character and the digit grouping character has also changed, but the problem is the same.

Anyone with ideas on how to solve this problem?

+4
2

, - , - Java 7 Java 8. , :

double x = 22.44;
DecimalFormat df = new DecimalFormat("0.00", new DecimalFormatSymbols(Locale.FRANCE));
System.out.println(df.format(x));

df = new DecimalFormat("0.00", new DecimalFormatSymbols(Locale.UK));
System.out.println(df.format(x));

:

22,44 ( )
22.44 ( )

+4

, .

. .

+4

Source: https://habr.com/ru/post/1679106/


All Articles