请教正则验证HH:mm格式的时间字符串,严格匹配,符合24小时的时钟规律,匹配时如何控制到00-24? 如00:00 - 24:00
String time = "12:34";
Pattern p = Pattern.compile("^([01][0-9]|2[0-3]):([0-5][0-9])$");
Matcher m = p.matcher(time);
if(m.find()){
System.out.println("HH:" + m.group(1));
System.out.println("mm:" + m.group(2));
System.out.println("HH:mm:" + m.group());
}