I’m getting the following error when trying to parse the phone number, “5554567899”
java.lang.NumberFormatException: For input string: "5554567899"
at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)
at java.lang.Integer.parseInt(Integer.java:495)
at java.lang.Integer.parseInt(Integer.java:527)
...
Obviously, the phone number is able to be parsed. I even referenced this question, and the byte code result was
53,53,53,52,53,54,55,56,57,57,
So there’s no invisible characters in the string. I’m stumped, can anyone help?
Here’s the section of the code that’s throwing the error, for reference:
String fullNumber = null;
for(Phone phone : party.getPhones()) {
if(phone != null && !phone.getDialNumber().isEmpty()) {
if(!phone.getAreaCode().isEmpty()) {
fullNumber = phone.getAreaCode();
}
fullNumber += phone.getDialNumber();
if(phone1 == null || phone1.equals(0)) {
LOGGER.debug(displayCharValues(fullNumber));
phone1 = Integer.parseInt(fullNumber);
}
}
phone1 is of Java.lang.Integer type.
The value exceeds the int range. Parse it into a long variable.
Simple test:
is a compile time error: “The literal 5554567899 of type int is out of range”