package com.etc.jichu; import java.text.SimpleDateFormat; public class IsDate { public static boolean isValidDate(String str) { boolean convertSuccess=true; SimpleDateFormat format=new SimpleDateFormat("YYYY/MM/dd HH:mm"); try { format.setLenient(false);//不宽松地验证日期 format.parse(str); } catch (Exception e) { convertSuccess=false;//若 抛java.text.ParseException或者NullPointerException,就说明格式不对 } return convertSuccess; } }
时间: 2024-10-13 20:27:03