Creates a matcher that matches when the examined {@linkplain Date} has the given values <code>year</code>, <code>
id</code> and <code>day</code>.
3178
public static Matcher<Date> hasYearMonthAndDay(final int year, final int month, final int day) {
        return new IsDate(year, month, day);
    }
172442
@Override
    public Date asDate() {
        final Class<?> callerClass = ReflectionHelper.getDirectCallerClass();
        return evaluateSingeValue(Date.class, callerClass);
    }
1048226
private static ArrayList<DateMatch> matchDatesWithoutSeparator(Configuration configuration, String password)
    {

        // Initialize the list of matching dates
        ArrayList<DateMatch> dateMatches = new ArrayList<>();

        // Create all possible subsequences of the password
        for (int start = 0; start < password.length(); start++)
        {
            for (int end = start + 4; end <= password.length(); end++)
            {

                // Get the subsequence
                String passwordChunk = password.substring(start, end);

                // Quick verfication that it is made of numbers
                if (DATE_WITHOUT_SEPARATOR.matcher(passwordChunk).find())
                {

                    // Extract the possible combinaison of dateAndMonth/year from the
                    // subsequence (eg: 121234 => 1212/34 and 12/1234)
                    ArrayList<PartialDateSplit> possiblePartialSplit = new ArrayList<>();
                    int chunkLength = passwordChunk.length();
                    if (chunkLength <= 6)
                    {
                        // start with a 2 digits year
                        possiblePartialSplit.add(new PartialDateSplit(
                                passwordChunk.substring(2),
                                passwordChunk.substring(0, 2)
                        ));
                        // end with a 2 digits year
                        possiblePartialSplit.add(new PartialDateSplit(
                                passwordChunk.substring(0, chunkLength - 2),
                                passwordChunk.substring(chunkLength - 2, chunkLength)
                        ));
                    }
                    if (chunkLength >= 6)
                    {
                        // start with a 4 digits year
                        possiblePartialSplit.add(new PartialDateSplit(
                                passwordChunk.substring(4),
                                passwordChunk.substring(0, 4)
                        ));
                        // end with a 4 digits year
                        possiblePartialSplit.add(new PartialDateSplit(
                                passwordChunk.substring(0, chunkLength - 4),
                                passwordChunk.substring(chunkLength - 4, chunkLength)
                        ));
                    }

                    // For each dateAndMonth/year extract the different possible full date
                    // (eg: 123/1998 => 1/23/1998 and 12/3/1998)
                    ArrayList<FullDateSplit> possibleFullSplit = new ArrayList<>();
                    for (PartialDateSplit split : possiblePartialSplit)
                    {
                        int dateAndMonthLength = split.dateAndMonth.length();
                        if (dateAndMonthLength == 2)
                        {
                            possibleFullSplit.add(new FullDateSplit(
                                    split.dateAndMonth.substring(0, 1),
                                    split.dateAndMonth.substring(1, 2),
                                    split.year
                            ));
                        }
                        else if (dateAndMonthLength == 3)
                        {
                            possibleFullSplit.add(new FullDateSplit(
                                    split.dateAndMonth.substring(0, 1),
                                    split.dateAndMonth.substring(1, 3),
                                    split.year
                            ));
                            possibleFullSplit.add(new FullDateSplit(
                                    split.dateAndMonth.substring(0, 2),
                                    split.dateAndMonth.substring(2, 3),
                                    split.year
                            ));
                        }
                        else if (dateAndMonthLength == 4)
                        {
                            possibleFullSplit.add(new FullDateSplit(
                                    split.dateAndMonth.substring(0, 2),
                                    split.dateAndMonth.substring(2, 4),
                                    split.year
                            ));
                        }
                    }

                    // Add to the final date list all the valid dates
                    for (FullDateSplit split : possibleFullSplit)
                    {
                        ValidDateSplit vSplit = isDateValid(split.date, split.month, split.year);
                        if (vSplit != null)
                        {
                            dateMatches.add(new DateMatch(passwordChunk, configuration, vSplit.date, vSplit.month, vSplit.year, "", start, end - 1));
                        }
                    }

                }
            }
        }

        return dateMatches;

    }
1135118
void selectDay(int year, int month, int day) {
        Calendar cal = Calendar.getInstance();
        cal.set(year, month, day);
        Date date = cal.getTime();
        this.field.setText(simpleDateFormat.format(date));
        if (popup != null) {
            popup.hide();
            popup = null;
        }
    }
343398
public static CronConstraint ensureEitherDayOfYearOrMonth() {
        return new CronConstraint("Both, a day-of-year AND a day-of-month or day-of-week, are not supported.") {
            private static final long serialVersionUID = 520379111876897579L;

            @Override
            public boolean validate(Cron cron) {
                CronField dayOfYearField = cron.retrieve(CronFieldName.DAY_OF_YEAR);
                if (dayOfYearField != null && !(dayOfYearField.getExpression() instanceof QuestionMark)) {
                    return cron.retrieve(CronFieldName.DAY_OF_WEEK).getExpression() instanceof QuestionMark
                            && cron.retrieve(CronFieldName.DAY_OF_MONTH).getExpression() instanceof QuestionMark;
                }

                return true;
            }
        };
    }
552127
public <U extends T> OngoingMatchingC1<T, U, U> when(MatchesAny<U> o) {
    List<Matcher<Object>> matchers = Lists.of(ArgumentMatchers.any());
    return new OngoingMatchingC1<>(
        this,
        new DecomposableMatchBuilder1<U, U>(matchers, 0, new IdentityFieldExtractor<>()).build());
  }
527480
private boolean setDate(String day, String month, String year) {
        click();
        String fullDate = monthYearButton.getText().trim();
        if (!fullDate.contains(month) || !fullDate.contains(year)) {
            monthYearButton.click();
            goToYear(year, fullDate);
            WebLocator yearEl = new WebLocator(yearContainer).setText(year, SearchType.EQUALS).setInfoMessage("year " + year);
            yearEl.click();
            WebLocator yearContainer1 = new WebLocator(yearAndMonth).setClasses("x-date-mp-year", "x-date-mp-sel");
            WebLocator yearEl1 = new WebLocator(yearContainer1).setText(year, SearchType.EQUALS);
            if (!yearEl1.ready(1)) {
                yearEl.click();
            }
            WebLocator monthEl = new WebLocator(monthContainer).setText(month, SearchType.EQUALS).setInfoMessage("month " + month);
            monthEl.click();
            selectOkButton.click();
        }
        WebLocator dayEl = new WebLocator(dayContainer).setText(day, SearchType.EQUALS).setInfoMessage("day " + day);
        dayEl.click();
        return true;
    }
767865
public static boolean matches(String pattern, String value) {
        Pattern p = Pattern.compile(pattern);
        Matcher m = p.matcher(value);
        return m.matches();
    }
1142466
public static boolean isDateAfterToday(String date) {
        if (isEmpty(date)) return defaultEmptyOK;
        int dateSlash1 = date.indexOf("/");
        int dateSlash2 = date.lastIndexOf("/");

        if (dateSlash1 <= 0) return false;

        java.util.Date passed = null;
        if (dateSlash1 == dateSlash2) {
            // consider the day to be optional; use the first day of the following month for comparison since this is an is after test
            String month = date.substring(0, dateSlash1);
            String day = "28";
            String year = date.substring(dateSlash1 + 1);
            if (!isDate(year, month, day)) return false;

            try {
                int monthInt = Integer.parseInt(month);
                int yearInt = Integer.parseInt(year);
                Calendar calendar = Calendar.getInstance();
                calendar.set(yearInt, monthInt - 1, 0, 0, 0, 0);
                calendar.add(Calendar.MONTH, 1);
                passed = new java.util.Date(calendar.getTime().getTime());
            } catch (Exception e) {
                passed = null;
            }
        } else {
            String month = date.substring(0, dateSlash1);
            String day = date.substring(dateSlash1 + 1, dateSlash2);
            String year = date.substring(dateSlash2 + 1);
            if (!isDate(year, month, day)) return false;
            passed = UtilDateTime.toDate(month, day, year, "0", "0", "0");
        }

        java.util.Date now = UtilDateTime.nowDate();
        if (passed != null) {
            return passed.after(now);
        } else {
            return false;
        }
    }
761211
public String[] match(String value) {
        if (value == null) {
            return null;
        }
        for (Pattern pattern : patterns) {
            Matcher matcher = pattern.matcher(value);
            if (matcher.matches()) {
                int count = matcher.groupCount();
                String[] groups = new String[count];
                for (int j = 0; j < count; j++) {
                    groups[j] = matcher.group(j + 1);
                }
                return groups;
            }
        }
        return null;
    }
662388
@Nullable
    public static Date parseDate(String dateValue, Collection<String> dateFormats) {
        return parseDate(dateValue, dateFormats, DEFAULT_TWO_DIGIT_YEAR_START);
    }
1256082
public static List<Date> matchedDates(String patternStr, Date start, int count, boolean isMatchSecond) {
		return matchedDates(patternStr, start, DateUtil.endOfYear(start), count, isMatchSecond);
	}
74764
function(dateString) {
        var match = dateString.match(DATE_REGEXP);

        var year = this._validateYear(+match[1]);

        var month = +match[2];
        var isIntercalary = !!match[3];
        var monthIndex = this.toMonthIndex(year, month, isIntercalary);

        var day = +match[4];

        return this.newDate(year, monthIndex, day);
    }
239030
public static boolean validate(final String date) {

        Matcher matcher = PATTERN.matcher(date);

        if (matcher.matches()) {

            matcher.reset();

            if (matcher.find()) {

                int year = Integer.parseInt(matcher.group(1));
                String month = matcher.group(2);
                String day = matcher.group(3);

                if (day.equals("31") && (month.equals("4") || month.equals("6") || month.equals("9") || month
                        .equals("11") || month.equals("04") || month.equals("06") || month.equals("09"))) {
                    return false; // only 1,3,5,7,8,10,12 has 31 days
                } else if (month.equals("2") || month.equals("02")) {
                    // leap year
                    if (year % 4 == 0) {
                        return !(day.equals("30") || day.equals("31"));
                    } else {
                        return !(day.equals("29") || day.equals("30") || day.equals("31"));
                    }
                } else {
                    return true;
                }
            } else {
                return false;
            }
        } else {
            return false;
        }
    }
942647
static final java.util.Date parseDate(String formatted) {
        if (formatted == null || formatted.trim().equals(""))
            return null;

        try {
            DatatypeFactory factory = DatatypeFactory.newInstance();
            XMLGregorianCalendar calendar = factory.newXMLGregorianCalendar(formatted);
            return calendar.toGregorianCalendar().getTime();
        }
        catch (Exception e) {
            Matcher matcher = PATTERN_DD_MM_YYYY.matcher(formatted);

            // Try matching dd.MM.yyyy date formats first
            if (matcher.find()) {
                String yyyy = matcher.group(3);
                String mm = matcher.group(2);
                String dd = matcher.group(1);
                String hh = defaultIfEmpty(matcher.group(4), "0");
                String min = defaultIfEmpty(matcher.group(5), "0");
                String ss = defaultIfEmpty(matcher.group(6), "0");
                String ms = defaultIfEmpty(matcher.group(7), "0");

                return getDate(Integer.parseInt(yyyy),
                               Integer.parseInt(mm),
                               Integer.parseInt(dd),
                               Integer.parseInt(hh),
                               Integer.parseInt(min),
                               Integer.parseInt(ss),
                               Integer.parseInt(ms));
            }

            // Then try matching yyyy-MM-dd date formats
            else {
                Matcher matcher2 = PATTERN_YYYY_MM_DD.matcher(formatted);

                if (matcher2.find()) {
                    String yyyy = matcher2.group(1);
                    String mm = defaultIfEmpty(matcher2.group(2), "1");
                    String dd = defaultIfEmpty(matcher2.group(3), "1");
                    String hh = defaultIfEmpty(matcher2.group(4), "0");
                    String min = defaultIfEmpty(matcher2.group(5), "0");
                    String ss = defaultIfEmpty(matcher2.group(6), "0");
                    String ms = defaultIfEmpty(matcher2.group(7), "0");

                    return getDate(Integer.parseInt(yyyy),
                                   Integer.parseInt(mm),
                                   Integer.parseInt(dd),
                                   Integer.parseInt(hh),
                                   Integer.parseInt(min),
                                   Integer.parseInt(ss),
                                   Integer.parseInt(ms));
                }

                // Finally, try matching plain timestamps
                else {
                    try {
                        return new Date(Long.parseLong(formatted));
                    } catch (NumberFormatException ignore) {
                        return null;
                    }
                }
            }
        }
    }
321411
private void parseAmbiguousDatesAsAfter(Date startDate) {
        defaultCenturyStart = startDate;
        calendar.setTime(startDate);
        defaultCenturyStartYear = calendar.get(Calendar.YEAR);
    }
808084
public static <D extends Comparable> DateExpression<D> addYears(DateExpression<D> date, int years) {
        return Expressions.dateOperation(date.getType(), Ops.DateTimeOps.ADD_YEARS, date, ConstantImpl.create(years));
    }