简体   繁体   English

异常-java.lang.NumberFormatException:对于输入字符串:“ 000000000”

[英]Exception- java.lang.NumberFormatException: For input string: “ 000000000”

I have this return after a query in database, I dont know what exactly means. 我在数据库中查询后有此返回,我不知道确切的意思。

Caused by: java.lang.NumberFormatException: For input string: " 000000000"

Someone help me please. 请有人帮我。 Thanks 谢谢

This issue caused by number format exception. 由数字格式异常引起的此问题。 There is space in format input string: " 000000000" . 格式输入字符串中有空格: “ 000000000” Remove the space and try it again 删除空间,然后重试

Look at this part of your error message: 查看错误消息的这一部分:
Caused by: java.lang.NumberFormatException: For input string: " 000000000"

Parsing the number is failing because there is a space at the beginning of your number String. 解析数字失败,因为数字String的开头有一个空格。

Remove that space and it should work. 删除该空间,它应该可以工作。

From the Javadoc for NumberFormatException 从Javadoc中获取NumberFormatException

Thrown to indicate that the application has attempted to convert a string to one of the numeric types, but that the string does not have the appropriate format. 引发以指示应用程序已尝试将字符串转换为数字类型之一,但是该字符串没有适当的格式。

In your case you have a space in the number, you can trim it with trim() 如果您的数字中有空格,则可以使用trim()对其进行trim()

How i can do this in number? 我该如何做到这一点?

Before attempting to parse the number you need to make sure it is formatted as a number. 在尝试解析数字之前,您需要确保将其格式化为数字。

eg 例如

String s = " 00000000";
int n = Integer.parseInt(s.trim()); // remove leading/trailing spaces.

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 java-线程“ main”中的异常java.lang.NumberFormatException:对于输入字符串:“”位于 - java - Exception in thread “main” java.lang.NumberFormatException: For input string: “” at 线程“ main”中的异常java.lang.NumberFormatException:对于输入字符串:Java中的“” - Exception in thread “main” java.lang.NumberFormatException: For input string: “” in Java 线程“ main”中的异常java.lang.NumberFormatException:对于输入字符串:“ 0.06” - Exception in thread “main” java.lang.NumberFormatException: For input string: “0.06” 线程“ Thread-3”中的异常java.lang.NumberFormatException:对于输入字符串:“” - Exception in thread “Thread-3” java.lang.NumberFormatException: For input string: “” 线程“main”中的异常 java.lang.NumberFormatException:对于输入字符串:“8/3/2012” - Exception in thread "main" java.lang.NumberFormatException: For input string: "8/3/2012" 线程“ main”中的异常java.lang.NumberFormatException:对于输入字符串:“” - Exception in thread “main” java.lang.NumberFormatException: For input string: “” 线程“main”中的异常 java.lang.NumberFormatException:对于输入字符串:“0.353” - Exception in thread “main” java.lang.NumberFormatException: For input string: “0.353” 线程“ main”中的异常java.lang.NumberFormatException:对于输入字符串:“; - Exception in thread “main” java.lang.NumberFormatException: For input string: "; 线程“ main”中的异常java.lang.NumberFormatException:对于输入字符串:“ 33” - Exception in thread “main” java.lang.NumberFormatException: For input string: “33” 线程“ main”中的异常java.lang.NumberFormatException:对于输入字符串:“” - Exception in thread “main” java.lang.NumberFormatException: For input string: “ ”
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM