If using Java 7 or higher, I would recommend using java.lang.Long; or java.lang.Integer; (if you are sure that you have to parse integers).
It works for both cases.
Edit further: I have not seen that you are using Integer.parseInt ();
Therefore, I assume that you have Java 6 or less.
In this case, try calling the following method before the line with Integer.parseInt(tempStr); to remove + if it exists:
private static String removePlusSignIfExists(String numberAsString) { if(numberAsString == null || numberAsString.length() == 0){ return numberAsString; } if(numberAsString.charAt(0) == '+'){ return numberAsString.substring(1, numberAsString.length()); } else { return numberAsString; } }
source share