I’m looking for a regex string that will validate dates formatted as yyyyMMdd (no delimiters) and works for leap years. The closest thing I found so far only validates dates since 2000.
import java.util.regex.Pattern;
public class TestDate {
public static final Pattern datePattern = Pattern.compile("** Need RegEx **");
public static void main(String[] args) {
System.out.println(datePattern.matcher("19960229").matches());
}
}
I suggest using the
java.text.DateFormatas shown in this page :