I try to convert this string "10 000.00" to double with method Double.valueOf and I've a input format error:
java.lang.NumberFormatException: For input string: "10 000.00"
How to convert it to double?
You can use:
Double.valueOf(input.replaceAll("[ ]",""));
in order to remove spaces before trying to convert.
Example :
public static void main(String[] args) {
System.out.print(Double.valueOf("10 000.00".replaceAll("[ ]","")));
}
Output :
10000.0
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With