1

The following code

if (Double.parseDouble(value) > 0)

throws the following exception

java.lang.NumberFormatException: Invalid double: "‎-2.49"


The logged value seems like a valid Double, what might cause this exception?

Oliver
  • 8,823
  • 8
  • 67
  • 97
Guy Levinger
  • 161
  • 3
  • 8
  • 1
    It seems like your string is valid. Maybe there is an invisible character in it, try [this code](http://stackoverflow.com/questions/10372862/java-string-remove-all-non-numeric-characters) to clean it up and see if it helps – Thyen Hong Guedes Chang Jun 09 '15 at 22:15

1 Answers1

0

You seem to encounter a locale issue. That is, integer and fractional part separators differ in different locales, somewhere it's . and somewhere ,.

See that question, there's a probable solution. Use the locale which fits the best for you, for example Locale.US uses . as the separator.

Community
  • 1
  • 1
hotkey
  • 127,445
  • 33
  • 333
  • 310