A DESCRIPTION OF THE REQUEST :
The only way to check if a numeric String has a valid format is to try to parse it an catch the exception thrown. I'm requesting an easy way to make sure that a String has a valid numeric format.
JUSTIFICATION :
Writing this kind of code to perform a basic task, to find out the validity of a number, is not acceptable.
boolean isNumeric = true; try{Integer.parseInt(fieldValue);}catch(Exception e){isNumeric = false;}
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
boolean isNumeric = Integer.isInt(s);
boolean isNumeric = Integer.isInt(s,radix);
Similar methods should be implemented in the Byte, Short, Integer, Long, Float and Double classes.
The only way to check if a numeric String has a valid format is to try to parse it an catch the exception thrown. I'm requesting an easy way to make sure that a String has a valid numeric format.
JUSTIFICATION :
Writing this kind of code to perform a basic task, to find out the validity of a number, is not acceptable.
boolean isNumeric = true; try{Integer.parseInt(fieldValue);}catch(Exception e){isNumeric = false;}
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
boolean isNumeric = Integer.isInt(s);
boolean isNumeric = Integer.isInt(s,radix);
Similar methods should be implemented in the Byte, Short, Integer, Long, Float and Double classes.
- duplicates
-
JDK-4487183 RFE: Want primitive wrapper classes to be able to test for NumberFormatException
-
- Closed
-