public static boolean checkDate(String dateStr){
boolean flag = false;
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd");
sdf.setLenient(false);//默认是true,日期会自动顺延,比如20181232会顺延成20190101,设置成false,就不自动顺延,20181232会报错
try {
sdf.parse(dateStr);
flag = true;
} catch (ParseException e) {
return flag;
}
return flag;
}