I have the following String:
String p = "33,644.234";
How can I convert it to double value?
Following gives java.lang.NumberFormatException: For input string: "33,644.234"
System.out.println(Double.valueOf(p));
kindly suggest.
I have the following String:
String p = "33,644.234";
How can I convert it to double value?
Following gives java.lang.NumberFormatException: For input string: "33,644.234"
System.out.println(Double.valueOf(p));
kindly suggest.
Remove the comma and then parse it.
double d = Double.parseDouble(p.replace(",",""));
Based on the OP's update, he wants the double to print in the original form, with the comma. The answer to that comes from this question.
System.out.println(String.format("%1$,.2f", d));
Output:
33,644.23