改变SimpleDateFormat format = new SimpleDateFormat(“yyyyMMdd”);中的格式即可
public static boolean isValidDate(String str) {
boolean convertSuccess=true;
SimpleDateFormat format = new SimpleDateFormat("yyyyMMdd");
try {
format.setLenient(false);
format.parse(str);
} catch (ParseException e) {
convertSuccess=false;
}
return convertSuccess;
}