Android的 - 解析字符串经度浮动的原因错误 [英] Android - parse String longitude to float causes error
本文介绍了Android的 - 解析字符串经度浮动的原因错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要转换我的CMS数据(作为字符串提供)浮动值,但我正在逐渐例外
NumberFormatException异常:无效的浮点值:16.385837
在code如下:
Double.valueOf(myString.trim())的doubleValue()。
我也试过这样的:
Double.parseDouble(MyString的).doubleValue();
但我得到了同样的信息。你有什么想法有什么不好?!
解决方案
{尝试
字符串s =16.385837;
双D = Double.parseDouble(S);
的System.out.println(D); //将打印16.385837
}赶上(NumberFormatException的E){
//没有P包含一个有效的双
}
I need to convert my CMS data (which are provided as Strings) to float value, but I am getting exception
NumberFormatException: invalid float value: "16.385837"
The code looks like:
Double.valueOf(myString.trim()).doubleValue();
I've also tried like this:
Double.parseDouble(myString).doubleValue();
but i'm getting the same message. Do you have any idea what is wrong ?!
解决方案
try {
String s = "16.385837";
Double d = Double.parseDouble(s);
System.out.println(d);// which will prints 16.385837
} catch (NumberFormatException e) {
// p did not contain a valid double
}
这篇关于Android的 - 解析字符串经度浮动的原因错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文