I have to do a validation where it is mentioned that phone number should be 10 digits like 9867610012 and if its true I have to set its value in a setter method whose argument is an Integer and I can't change it's argument. As we know, Integer has a minimum value of -2,147,483,648 and a maximum value of 2,147,483,647 (inclusive). When I parse the String to Integer using Integer.parseInt("9867610012"), I am getting following exception at runtime:
Exception in thread "main" java.lang.NumberFormatException: For input string: "9867610012".
Can you suggest some way where I can set a 10 digit String to Integer.
Thanks in Advance!!!!
Long.parseLong()+.