开发者

Java number format - #.## - Windows and Linux

开发者 https://www.devze.com 2023-04-10 04:21 出处:网络
I\'m using following code to format Double number De开发者_如何学运维cimalFormat decimalFormat=new DecimalFormat(\"#.##\");

I'm using following code to format Double number

De开发者_如何学运维cimalFormat decimalFormat=new DecimalFormat("#.##");
decimalFormat.format(1.04)

but this gives

java.lang.NumberFormatException: For input string: "1,04"

in Linux - but in Windows 7 this works fine, how to correct this?


There seems to be a very similar question answered here ( DecimalFormat and Double.valueOf() ) about the java number format. Basically the diference you are experiencing may be related to the Locale Settings defined on Windows being different to the Linux one (for example: on Windows you configured it to a contry/language different then the linux one).

0

精彩评论

暂无评论...
验证码 换一张
取 消