//匹配yyyymmdd
public static boolean valiDateTimeWithLongFormat(String timeStr) {
String reg_yyyyMMdd = "(([0-9]{3}[1-9]|[0-9]{2}[1-9][0-9]{1}|[0-9]{1}[1-9][0-9]{2}|[1-9][0-9]{3})(((0[13578]|1[02])(0[1-9]|[12][0-9]|3[01]))" +
"|((0[469]|11)(0[1-9]|[12][0-9]|30))|(02(0[1-9]|[1][0-9]|2[0-8]))))" +
"|((([0-9]{2})(0[48]|[2468][048]|[13579][26])|((0[48]|[2468][048]|[3579][26])00))0229)";
Pattern p = Pattern.compile(reg_yyyyMMdd);
return p.matcher(timeStr).matches();
}
//一、匹配时间
//①匹配[yyyy-MM-dd]的正则表达式:
String reg_yyyy_MM_dd = "(([0-9]{3}[1-9]|[0-9]{2}1-9{1}|[0-9]{1}1-9{2}|1-9{3})" +
"-(((0[13578]|1[02])-(0[1-9]|12|3[01]))|((0[469]|11)-(0[1-9]|12|30))|(02-(0[1-9]|1|2[0-8]))))" +
"|((([0-9]{2})(0[48]|2468|13579)|((0[48]|2468|3579)00))-02-29)";
//②匹配[yyyyMMdd]的正则表达式:
String reg_yyyyMMdd = "(([0-9]{3}[1-9]|[0-9]{2}1-9{1}|[0-9]{1}1-9{2}|1-9{3})(((0[13578]|1[02])(0[1-9]|12|3[01]))" +
"|((0[469]|11)(0[1-9]|12|30))|(02(0[1-9]|1|2[0-8]))))" +
"|((([0-9]{2})(0[48]|2468|13579)|((0[48]|2468|3579)00))0229)";
//③匹配[dd/MM/yyyy]的正则表达式:
String reg_dd_MM_yyyy = "(((0[1-9]|12|3[01])/((0[13578]|1[02]))|((0[1-9]|12|30)/(0[469]|11))|(0[1-9]|1|2[0-8])/(02))" +
"/([0-9]{3}[1-9]|[0-9]{2}1-9{1}|[0-9]{1}1-9{2}|1-9{3}))|" +
"(29/02/(([0-9]{2})(0[48]|2468|13579)|((0[48]|2468|3579)00)))";