Validates the users inputted date value

@param date The Date in String form
@param locale          Check format according to this locale
@return true if user inputted corect format, otherwise false
324272
public static boolean validateDateFormat(String date, Locale locale) {
        SimpleDateFormat df;
        SimpleDateFormat sdf;
        java.text.ParsePosition pos;
        java.util.Date dbDate;

        dbDate = null;
        try {
            if (date == null || date.equals("")) {
                return false;
            }

            df = (SimpleDateFormat) DateFormat.getDateInstance(
                    dateStyle,
                    locale
            );

            sdf = new SimpleDateFormat(df.toPattern());
            pos = new java.text.ParsePosition(0);
            sdf.setLenient(false);
            dbDate = sdf.parse(date, pos);

            return dbDate != null && dbDate.getTime() > 0L;

        } catch (Exception e) {
            return false;
        }
    }
14121
public static function isDateFormat($date, $format = 'Y-m-d')
    {
        if (!$unixTime = strtotime($date)) {
            return false;
        }

        // 校验日期的格式有效性
        if (date($format, $unixTime) === $date) {
            return true;
        }

        return false;
    }
636943
public function validateDate($date)
    {
        $subs = null;
        $check1 = preg_match("/^([\d]{4})-([\d]{2})-([\d]{2})$/i", $date, $subs);
        if(!$check1) {
            return false;
        }
        return checkdate($subs[2], $subs[3], $subs[1]);
    }
514816
function isValid(date) {
  return Object.prototype.toString.call(date) == '[object Date]' && !isNaN(date.getTime());
}
40572
public boolean contains(final LocalDate date) {
        if (date == null){
            return false;
        }
        if (endDate() == null) {
            if (startDate() == null) {
                return true;
            }
            if (date.isEqual(startDate()) || date.isAfter(startDate())) {
                return true;
            }
            return false;
        }
        return asInterval().contains(date.toInterval());
    }
1045865
public static function validateDate(string $date): bool
    {
        $date = Text::keepNumeric($date);
        $day = (int)substr($date, 0, 2);
        $month = (int)substr($date, 2, 2);
        if ($month < 0 || $month > 12) {
            return false;
        }
        // @formatter:off
        $months = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
        // @formatter:on
        if ((int)substr($date, 4, 2) % 4 === 0) {
            $months[1] = 29;
        }

        return $day > 0 && $day <= $months[$month - 1];
    }
129594
public static boolean isAm(Date date) {

        String time = getTime(date);
        return time.toLowerCase().contains(AM);
    }
520931
public static boolean isValidDate(final String date, final String format, final boolean lenient)
	{
		boolean isValid = true;
		if (date == null || format == null || format.length() <= 0)
		{
			return false;
		}
		try
		{
			final DateFormat df = new SimpleDateFormat(format);
			df.setLenient(lenient);
			df.parse(date);
		}
		catch (final ParseException | IllegalArgumentException e)
		{
			isValid = false;
		}
		return isValid;
	}
133175
private boolean validatePast(Object validationObject, Annotation annotate)
    {
        if (checkNullObject(validationObject))
        {
            return true;
        }

        int res = 0;

        if (validationObject.getClass().isAssignableFrom(java.util.Date.class))
        {
            Date today = new Date();
            Date pastDate = (Date) validationObject;

            res = pastDate.compareTo(today);
        }
        else if (validationObject.getClass().isAssignableFrom(java.util.Calendar.class))
        {

            Calendar cal = Calendar.getInstance();
            Calendar pastDate = (Calendar) validationObject;
            res = pastDate.compareTo(cal);

        }
        // else
        // {
        // ruleExceptionHandler(((Past) annotate).message());
        // }
        if (res >= 0)
        {
            throwValidationException(((Past) annotate).message());
        }

        return true;
    }
1204142
private function isValidDate(string $date, string $format = 'Y-m-d') : bool
    {
        $d = DateTime::createFromFormat($format, $date);
        // The Y ( 4 digits year ) returns TRUE for any integer with any number of digits so changing the comparison from == to === fixes the issue.
        return $d && $d->format($format) === $date;
    }
433905
public boolean contains(Date date)
   {
      boolean result = false;

      if (date != null)
      {
         result = (DateHelper.compare(getFromDate(), getToDate(), date) == 0);
      }

      return (result);
   }
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;
        }
    }
10501
public void setDate(Date date) {
        DateFormat df = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
        df.setTimeZone(TimeZone.getTimeZone("GMT"));
        setDate(df.format(date));
    }
1275639
public function checkLocalizedDate($value, ExecutionContextInterface $context)
    {
        $format = LangQuery::create()->findOneByByDefault(true)->getDatetimeFormat();

        if (false === \DateTime::createFromFormat($format, $value)) {
            $context->addViolation(
                Translator::getInstance()->trans(
                    "Date '%date' is invalid, please enter a valid date using %fmt format",
                    [
                        '%fmt'  => $format,
                        '%date' => $value
                    ]
                )
            );
        }
    }
3556
private function isValidFormat($date)
    {
        foreach ($this->formats as $format) {
            if (date($format, strtotime($date)) == $date) {
                return true;
            }
        }

        return false;
    }
750558
private function checkDateIsValid($date, $canBeNull = false)
    {
        if ($date === null
            && $canBeNull
        ) {
            return;
        }

        Date::factory($date);
    }
958205
private static String formatDate(Date date) {

        String dateStr = dateFormat.format(date);
        // insert colon into timezone
        return dateStr.substring(0, 22) + ":" + dateStr.substring(22);
    }