Java Regex Date Vaidate dateMatcher(String dt)

Here you can find the source of dateMatcher(String dt)

Description

date Matcher

License

Apache License

Declaration

public static boolean dateMatcher(String dt) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class Main {

    public static boolean dateMatcher(String dt) {
        Pattern pattern = Pattern.compile(
                "((((0[0-9])(([02468][48])|([13579][26]))-0?2-29))|(((0[0-9])(([2468][048])|([13579][26]))-0?2-29))|(((0[1-9])(([02468][048])|([13579][26]))-0?2-29))|((([1-9][0-9])(([02468][048])|([13579][26]))-0?2-29))|((0[0-9][0-9][1-9])|(0[0-9][1-9][0-9])|(0[1-9][0-9][0-9])|([1-9][0-9][0-9][0-9]))-((((0?[1-9])|(1[0-2]))-((0?[1-9])|(1[0-9])|(2[0-8])))|((((0?[13578])|(1[02]))-31)|(((0?[1,3-9])|(1[0-2]))-(29|30)))))");
        Matcher matcher = pattern.matcher(dt);
        return matcher.matches();
    }//from w ww .  j  a  v  a 2 s . c  om
}

Related

  1. checkDate(String date)
  2. checkDate(String strDate, String dateFmt)
  3. checkDateYYYYMMMDD(String date)
  4. dateOfAny(final String value)
  5. datePatternPattern(String appenderPrefix)
  6. dateTimeMatcher(String dt)
  7. dateTimePattern()