public static boolean
isIntegerNumeric(String s) {
try {
Integer.parseInt(s);
return true;
} catch(NumberFormatException e) {
return false;
}
}


public static boolean isDoubleNumeric(String s) {
try {
Double.parseDouble(s);
return true;
} catch(NumberFormatException e) {
return false;
}
}


public static boolean isFloatNumeric(String s) {
try {
Float.parseFloat(s);
return true;
} catch(NumberFormatException e) {
return false;
}
}


활용 방법


if (isIntegerNumeric(String) == false) {
logger.info("숫자만 입력 가능");
}


+ Recent posts