String str = "2007-01-02";
public static final DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
public boolean valid(String str){
try{
Date date = (Date)formatter.parse(str);
return str.equals(formatter.format(date));
}catch(Exception e){
return false;
}
}
java 判断格式是否正确
最新推荐文章于 2024-07-26 03:20:01 发布