public static boolean checkDate(String s) {
boolean b = false;
int year = Integer.parseInt(s.substring(0, 4));
int month = Integer.parseInt(s.substring(4, 6));
int day = Integer.parseInt(s.substring(6, 8));
switch (month) {
case 1:
;
case 3:
;
case 5:
;
case 7:
;
case 8:
;
case 10:
;
case 12:
if (day <= 31) b = true;
break;
case 4:
;
case 6:
;
case 9:
;
case 11:
if (day <= 30) b = true;
break;
case 2:
if (year % 4 == 0 && day <= 29) b = true;
else if (year % 4 != 0 && day <= 28) b = true;
default:
}
return b;
}
输入20200202