Here you can find the source of dateTimeMatcher(String dt)
public static boolean dateTimeMatcher(String dt)
//package com.java2s; //License from project: Apache License import java.util.regex.Matcher; import java.util.regex.Pattern; public class Main { public static boolean dateTimeMatcher(String dt) { Pattern pattern = Pattern.compile( "^(((20[0-3][0-9]-(0[13578]|1[02])-(0[1-9]|[12][0-9]|3[01]))|(20[0-3][0-9]-(0[2469]|11)-(0[1-9]|[12][0-9]|30))) (20|21|22|23|[0-1][0-9]):[0-5][0-9]:[0-5][0-9])$"); Matcher matcher = pattern.matcher(dt); return matcher.matches(); }/*from w ww . ja va2 s . c o m*/ }