LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   Java NumberFormatException with a valid number/string (https://www.linuxquestions.org/questions/programming-9/java-numberformatexception-with-a-valid-number-string-690455/)

manolakis 12-14-2008 02:28 AM

Java NumberFormatException with a valid number/string
 
Hi there,

I have a method like the following:

Quote:

public long getAsLong(String number)
{
return new Long(number).longValue();
}
My problem is that I get an exception such as the following:

Quote:

java.lang.FormatException For input string: "1223242177912"
As you can see the string that is parsed is indeed a valid long number. Does anybody know why it results to a problem. Any ideas how to overcome it?

Thank you.

CroMagnon 12-14-2008 04:59 AM

This works for me. Is that error pasted without any editing? What JVM and version are you using? What is the code that calls getAsLong?


All times are GMT -5. The time now is 11:42 PM.