I am trying to convert a string to Integer/Float/Double
but I got a NumberFormatException
.
My String is 37,78584
, Now I am converting this to any of them I got NumberFormatException
.
How can I convert this string
to any of them.
Please help me to get out of this problem.
You have to use the appropriate locale for the number like
String s = "37,78584";
Number number = NumberFormat.getNumberInstance(Locale.FRENCH).parse(s);
double d= number.doubleValue();
System.out.println(d);
prints
37.78584
Replace ,
by ""
blank in string and then convert your numbers
String str = "37,78584";
str = str.replaceAll("\\,","");
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