TextValidator { public static boolean isDate(@Nullable CharSequence input) { return isMatch(PATTERN_REGEX_DATE, input); }  static boolean isMobileSimple(@Nullable CharSequence input); static boolean isMobileExact(@Nullable CharSequence input); static boolean isTel(@Nullable CharSequence input); static boolean isIdCard(@Nullable CharSequence input); static boolean isEmail(@Nullable CharSequence input); static boolean isUrl(@Nullable CharSequence input); static boolean isDate(@Nullable CharSequence input); static boolean isIp(@Nullable CharSequence input); static boolean isMatch(Pattern pattern, CharSequence input); static final String REGEX_MOBILE_EXACT; }
@Test public void isDate() { assertThat(TextValidator.isDate("2011-02-29")).isFalse(); assertThat(TextValidator.isDate("201a-02-30")).isFalse(); assertThat(TextValidator.isDate("2011-0211")).isFalse(); assertThat(TextValidator.isDate("2011-03-11")).isTrue(); assertThat(TextValidator.isDate("2012-02-29")).isTrue(); }