/**
* 校驗時間字符串是否合法
*
* @param dateStr the date str
* @param pattern the pattern
* @return the boolean
*/
public static boolean validDateStr(String dateStr, String pattern) {
if (StringUtil.isEmpty(pattern)) {
pattern = "yyyy-MM-dd HH:mm:ss";
}
try {
LocalDate.parse(dateStr, new DateTimeFormatterBuilder().appendPattern(pattern).parseStrict().toFormatter());
return true;
} catch (Exception e) {
return false;
}
}