我想字符串转换为整数/浮点/双精度
,但我得到了一个 NumberFormatException异常
。
I am trying to convert a string to Integer/Float/Double
but I got a NumberFormatException
.
我的字符串是 37,78584
,现在我把它转换到任何一个我得到了 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.
请帮我走出这个问题。
您必须使用适当的区域设置的数量像
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);
打印
37.78584