BrTkCa
BrTkCa

Reputation: 4783

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

Upvotes: 1

Views: 2829

Answers (3)

Mohit Sharma
Mohit Sharma

Reputation: 187

This issue caused by number format exception. There is space in format input string: " 000000000". Remove the space and try it again

Upvotes: 3

Peter Lawrey
Peter Lawrey

Reputation: 533870

From the Javadoc for 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()

How i can do this in number?

Before attempting to parse the number you need to make sure it is formatted as a number.

e.g.

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

Upvotes: 2

George Mulligan
George Mulligan

Reputation: 11923

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.

Remove that space and it should work.

Upvotes: 2

Related Questions