It's not a secret anymore!*
The moose likes Java in General and the fly likes java.lang.NumberFormatException Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "java.lang.NumberFormatException" Watch "java.lang.NumberFormatException" New topic
Author

java.lang.NumberFormatException

nikil shar
Ranch Hand

Joined: May 25, 2008
Posts: 116
hi all,
i get this error when trying to parse a string :

java.lang.NumberFormatException: For input string: "12345501297"




i dont see why it throws this error ??

thanks in advance.
Vijitha Kumara
Bartender

Joined: Mar 24, 2008
Posts: 3838

The value you are trying to parse is too large for "int" type. Check with "Integer.MAX_VALUE".


SCJP 5 | SCWCD 5
[How to ask questions] [Twitter]
chandrakant karale
Ranch Hand

Joined: Nov 21, 2007
Posts: 41


If you are dealing with large account numbers, use long as datatype; replace Integer.parseInt by Long.parseLong.
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19723
    
  20

And if they still don't fit you have little option but to use BigInteger.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: java.lang.NumberFormatException