How can I convert a String
such as \"12.34\"
to a double
in Java?
There is another way too.
Double temp = Double.valueOf(str);
number = temp.doubleValue();
Double is a class and "temp" is a variable. "number" is the final number you are looking for.
Try this, BigDecimal bdVal = new BigDecimal(str);
If you want Double only then try Double d = Double.valueOf(str); System.out.println(String.format("%.3f", new BigDecimal(d)));