验证字符串是一个合法的时间
作者:互联网
public static Boolean isTimeStr(String validateDate, String format) {
boolean flag = false;
try {
DateUtil.parse(validateDate, format);
flag = true;
} catch (Exception e) {
e.printStackTrace();
}
return flag;
}
public static Boolean isTimeStr(String validateDate) {
boolean flag = false;
try {
DateUtil.parse(validateDate, "yyyy-MM-dd HH:mm:ss");
flag = true;
} catch (Exception e) {
e.printStackTrace();
}
return flag;
}
标签:false,String,验证,isTimeStr,合法,parse,flag,字符串,validateDate 来源: https://www.cnblogs.com/hhddd-1024/p/16447515.html