The way you check a single character to be digit is not with Integer.parseInt
(that one returns, an int
, not a boolean
). You use Character.isDigit
instead:
else if (strPos.length() > 4 && Character.isDigit(strPos.charAt(4)))
Note that it's checking the character at index 4, which is the fifth character (the initial character is at index zero, not one).