List of utility methods to do Regex Date Vaidate
boolean | checkDate(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])" ... |
boolean | checkDate(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(); |
boolean | checkDateYYYYMMMDD(String date) check Date YYYYMMMDD String regex = "[1|2][0-9]{7}"; return Pattern.matches(regex, date); |
boolean | dateMatcher(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(); |
Date | dateOfAny(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); ... |
Pattern | datePatternPattern(String appenderPrefix) date Pattern Pattern return Pattern.compile( "(^\\s*" + appenderPrefix + "\\.DatePattern\\s*=\\s*'\\.')" + datePatternPatternString + "\\s*$"); |
boolean | dateTimeMatcher(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(); |
Pattern | dateTimePattern() date Time Pattern return dateTimePattern;
|
String | dateToString(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"; |
DateTime | parseDate(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(" ")); |