public static boolean isValidDate(String str) { DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd"); try{ Date date = (Date)formatter.parse(str); return str.equals(formatter.format(date)); }catch(Exception e){ return false; }}
本文共 325 字,大约阅读时间需要 1 分钟。
public static boolean isValidDate(String str) { DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd"); try{ Date date = (Date)formatter.parse(str); return str.equals(formatter.format(date)); }catch(Exception e){ return false; }}
转载于:https://www.cnblogs.com/sunBinary/p/9971088.html