Java Utililty Methods Regex Date Vaidate

List of utility methods to do Regex Date Vaidate

Description

The list of methods to do Regex Date Vaidate are organized into topic(s).

Method

booleancheckDate(String date)
check Date
String regex = "^((\\d{2}(([02468][048])|([13579][26]))[\\-\\/\\s]?"
        + "((((0?[13578])|(1[02]))[\\-\\/\\s]?((0?[1-9])|([1-2][0-9])|(3[01])))"
        + "|(((0?[469])|(11))[\\-\\/\\s]?((0?[1-9])|([1-2][0-9])|(30)))"
        + "|(0?2[\\-\\/\\s]?((0?[1-9])|([1-2][0-9])))))|(\\d{2}(([02468][1235679])"
        + "|([13579][01345789]))[\\-\\/\\s]?((((0?[13578])|(1[02]))[\\-\\/\\s]"
        + "?((0?[1-9])|([1-2][0-9])|(3[01])))|(((0?[469])|(11))[\\-\\/\\s]"
        + "?((0?[1-9])|([1-2][0-9])|(30)))|(0?2[\\-\\/\\s]"
        + "?((0?[1-9])|(1[0-9])|(2[0-8]))))))(\\s(((0?[0-9])"
...
booleancheckDate(String strDate, String dateFmt)
check Date
String eL = "";
if ("yyyy-MM-dd".equals(dateFmt)) {
    eL = "^((\\d{2}(([02468][048])|([13579][26]))\\-((((0?[13578])|(1[02]))\\-((0?[1-9])|([1-2][0-9])|(3[01])))|(((0?[469])|(11))\\-((0?[1-9])|([1-2][0-9])|(30)))|(0?2\\-((0?[1-9])|([1-2][0-9])))))|(\\d{2}(([02468][1235679])|([13579][01345789]))\\-((((0?[13578])|(1[02]))\\-((0?[1-9])|([1-2][0-9])|(3[01])))|(((0?[469])|(11))\\-((0?[1-9])|([1-2][0-9])|(30)))|(0?2\\-((0?[1-9])|(1[0-9])|(2[0-8]))))))$";
Pattern p = Pattern.compile(eL);
Matcher m = p.matcher(strDate);
return m.matches();
booleancheckDateYYYYMMMDD(String date)
check Date YYYYMMMDD
String regex = "[1|2][0-9]{7}";
return Pattern.matches(regex, date);
booleandateMatcher(String dt)
date Matcher
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();
DatedateOfAny(final String value)
date Of Any
if (value == null || value.trim().length() == 0)
    return null;
Calendar calendat = Calendar.getInstance();
final String datePattern = "[0-9]{4}-([0-1]?[0-9])-(([0-3]?[0-9])|([3][0-1]))";
final String timePattern = "(([0-1]?[0-9])|([2][0-3]))((:([0-5]){0,1}([0-9]){1}){1,2})";
final String timesPattern = " ([0-1]?[0-9]){1}(((:([0-5]){0,1}([0-9]){1}){1,2}) (([AP]M)|([ap]m)))?";
Pattern p = Pattern.compile(datePattern);
Matcher m = p.matcher(value);
...
PatterndatePatternPattern(String appenderPrefix)
date Pattern Pattern
return Pattern.compile(
        "(^\\s*" + appenderPrefix + "\\.DatePattern\\s*=\\s*'\\.')" + datePatternPatternString + "\\s*$"); 
booleandateTimeMatcher(String dt)
date Time Matcher
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();
PatterndateTimePattern()
date Time Pattern
return dateTimePattern;
StringdateToString(Date date)
Return a String suitable for use as an edn #inst , given a Date .
GregorianCalendar c = new GregorianCalendar(GMT);
c.setTime(date);
String s = calendarToString(c);
assert s.endsWith("+00:00");
return s.substring(0, s.length() - 6) + "-00:00";
DateTimeparseDate(final String date, final DateTimeFormatter parser)
parse Date
final String trimmed = date.replace('\n', ' ').trim();
if (trimmed.isEmpty()) {
    return null;
final Matcher matcher = REPEATED_SPACES.matcher(trimmed);
return parser.parseDateTime(matcher.replaceAll(" "));