1

I'm using following code to format Double number

DecimalFormat 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?

Buddhi
  • 2,224
  • 5
  • 32
  • 43

1 Answers1

4

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).

Community
  • 1
  • 1
Gabriel Mazetto
  • 1,090
  • 1
  • 12
  • 23
  • I don't know what distro you are using, but I will give you the Ubuntu wiki instructions that will probably be similar or the same you are using right now: https://help.ubuntu.com/community/Locale Make sure all locale related variables are correctly defined. But also take a look of the suggestion on the link, as it seems to be more likely to be a permanent fix) – Gabriel Mazetto Oct 04 '11 at 04:48
  • Are you using the same Locale in both W7 and Linux? – YMomb Oct 04 '11 at 05:38