Results 1 to 3 of 3
Like Tree1Likes
  • 1 Post By Tolls

Thread: Number format Exception

  1. #1
    know_how is offline Member
    Join Date
    Jan 2013
    Posts
    6
    Rep Power
    0

    Default Number format Exception

    hello

    Actually a situation is like i have a form in index.jsp file as :
    Number format Exception-index.png

    and i have another file as newcard.jsp which looks like :
    Number format Exception-newcard.png


    ok when i enter the mob no = 0123456789 OR 0987654321 , it works fine

    but when i'm trying to enter no. like mob no =9876543210 OR 9927080800 OR 8877009944 , it throws an exception on newcard.jsp as :

    org.apache.jasper.JasperException: java.lang.NumberFormatException: For input string: "8877009944"


    i'm really confused what to do as exactly don't know where i'm going wrong...

    so please help me with a solution and explaination

    thanks in advance

  2. #2
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,450
    Rep Power
    19

    Default Re: Number format Exception

    What is the maximum size of an int?
    (Hint, it's less than the number you are trying to parse).

    Also, a phone number is not an int.
    It's a String that just happens to consist solely of digits.
    For example:
    01215551234
    might be a valid phone number, but if you converted that to an int you would get:
    1215551234
    which is not the same.

    ETA: Actually, just thought I'd add, it can also consist of a leading '+', if you're storing international dialling.
    know_how likes this.
    Please do not ask for code as refusal often offends.

  3. #3
    know_how is offline Member
    Join Date
    Jan 2013
    Posts
    6
    Rep Power
    0

Similar Threads

  1. Number format Exception
    By aortell24 in forum New To Java
    Replies: 5
    Last Post: 07-16-2012, 05:22 AM
  2. Number format
    By asai in forum New To Java
    Replies: 12
    Last Post: 06-21-2012, 10:24 AM
  3. Number Format Exception while parsing long
    By Aamir in forum Networking
    Replies: 2
    Last Post: 05-15-2011, 02:57 AM
  4. Replies: 7
    Last Post: 12-30-2010, 01:42 PM
  5. Replies: 16
    Last Post: 09-04-2010, 04:03 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •