Tries different date formats to parse against the given string
representation to retrieve a valid Date object.

@param strdate Date as String
@return Date The parsed Date
326001
public static Date parseDate(String strdate) {

        /* Return in case the string date is not set */
        if (strdate == null || strdate.length() == 0) return null;

        Date result = null;
        strdate = strdate.trim();
        if (strdate.length() > 10) {

            /* Open: deal with +4:00 (no zero before hour) */
            if ((strdate.substring(strdate.length() - 5).indexOf("+") == 0 || strdate.substring(strdate.length() - 5).indexOf("-") == 0) && strdate.substring(strdate.length() - 5).indexOf(":") == 2) { //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
                String sign = strdate.substring(strdate.length() - 5, strdate.length() - 4);
                strdate = strdate.substring(0, strdate.length() - 5) + sign + "0" + strdate.substring(strdate.length() - 4); //$NON-NLS-1$
            }

            String dateEnd = strdate.substring(strdate.length() - 6);

            /*
             * try to deal with -05:00 or +02:00 at end of date replace with -0500 or
             * +0200
             */
            if ((dateEnd.indexOf("-") == 0 || dateEnd.indexOf("+") == 0) && dateEnd.indexOf(":") == 3) { //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$
                if (!"GMT".equals(strdate.substring(strdate.length() - 9, strdate.length() - 6))) { //$NON-NLS-1$
                    String oldDate = strdate;
                    String newEnd = dateEnd.substring(0, 3) + dateEnd.substring(4);
                    strdate = oldDate.substring(0, oldDate.length() - 6) + newEnd;
                }
            }
        }

        /* Try to parse the date */
        int i = 0;
        while (i < CUSTOM_DATE_FORMATS.length) {
            try {

                /*
                 * This Block needs to be synchronized, because the parse-Method in
                 * SimpleDateFormat is not Thread-Safe.
                 */
                synchronized (CUSTOM_DATE_FORMATS[i]) {
                    return CUSTOM_DATE_FORMATS[i].parse(strdate);
                }
            } catch (ParseException e) {
                i++;
            } catch (NumberFormatException e) {
                i++;
            }
        }
        return result;
    }
745010
public int parseDate(String strValue, Date date)
    {
        int type = 0;
        if (strValue == null)
            return type;
        
        Date parsedDate = null;
        try {
                parsedDate = XmlUtilities.dateTimeFormat.parse(strValue);
                type = DBConstants.DATE_TIME_FORMAT;
        } catch (ParseException e) {
        }
        
        try {
            if (parsedDate == null)
            {
                parsedDate = XmlUtilities.dateFormat.parse(strValue);
                type = DBConstants.DATE_ONLY_FORMAT;
            }
        } catch (ParseException e) {
        }
        
        try {
            if (parsedDate == null)
            {
                parsedDate = XmlUtilities.timeFormat.parse(strValue);
                type = DBConstants.TIME_ONLY_FORMAT;
            }
        } catch (ParseException e) {
        }
        
        if (parsedDate != null)
            date.setTime(parsedDate.getTime());
        else
            type = 0;
        
        return type;
    }
223066
private static Date parseHTTPDateImpl(final String pDate) throws NumberFormatException  {
        if (pDate == null) {
            throw new IllegalArgumentException("date == null");
        }

        if (StringUtil.isEmpty(pDate)) {
            throw new NumberFormatException("Invalid HTTP date: \"" + pDate + "\"");
        }

        DateFormat format;

        if (pDate.indexOf('-') >= 0) {
            format = HTTP_RFC850_FORMAT;
            update50YearWindowIfNeeded();
        }
        else if (pDate.indexOf(',') < 0) {
            format = HTTP_ASCTIME_FORMAT;
            update50YearWindowIfNeeded();
        }
        else {
            format = HTTP_RFC1123_FORMAT;
            // NOTE: RFC1123 always uses 4-digit years
        }

        Date date;
        try {
            //noinspection SynchronizationOnLocalVariableOrMethodParameter
            synchronized (format) {
                date = format.parse(pDate);
            }
        }
        catch (ParseException e) {
            NumberFormatException nfe = new NumberFormatException("Invalid HTTP date: \"" + pDate + "\"");
            nfe.initCause(e);
            throw nfe;
        }

        if (date == null) {
            throw new NumberFormatException("Invalid HTTP date: \"" + pDate + "\"");
        }

        return date;
    }
734415
function parseDate(value) {
  let date = value;
  if (!value) {
    return new Date().getTime();
  }
  if (isObject(date)) {
    date = date.value || date;
  }
  // array
  if (isArray(date)) {
    date = new Date(...date).getTime();
  } else {
    // string number  null 、''、undefined
    date = new Date(date).getTime();
  }
  if (date) {
    return date;
  }
  console.warn('Invalid Date ', value);
  return new Date().getTime();
}
982201
static function isValidISODateString( $sDate )
	{
		if ( ! CLib::IsExistingString( $sDate ) )
		{
			return false;
		}

		$nTime	= strtotime( $sDate );
		return ( false !== $nTime &&
			0 == strcasecmp( $sDate, date( "Y-m-d", $nTime ) ) );
	}
1276793
private DateTime parseToDate(String toDate) {
        // Default to now
        return parseDate(toDate, new DateTime().withZone(DateTimeZone.UTC), false);
    }
128563
static Date parseDate(String dateString) {
    try {
      return DATE_FORMAT.parseDateTime(dateString).toDate();
    } catch (IllegalArgumentException e) {
      return null;
    }
  }
1195789
private static Date parseDate(@SuppressWarnings("SameParameterValue") String stringDate)
    {
        try {
            return formatter.parse(stringDate);
        } catch (ParseException e) {
            e.printStackTrace();
            return null;
        }
    }
345633
public static Date parseDate(final String dateValue, final String[] dateFormats) {
        return parseDate(dateValue, dateFormats, null);
    }
314500
public static java.util.Date parseDate(String strDate, String pattern) {
		try {
			SimpleDateFormat parser = new SimpleDateFormat(pattern, Locale.US);
			return parser.parse(strDate);
		} catch (ParseException e) {
			throw new JKException(e);
		}
	}
1028893
public static Date parseISO8601Date(String dateString) {
        try {
            return doParseISO8601Date(dateString);
        } catch(RuntimeException ex) {
            throw handleException(ex);
        }
    }
87288
@Override
  public final String toDateString(final Date pDate,
    final Map<String, Object> pAddParam) throws Exception {
    return this.dateFormat.format(pDate);
  }
243428
public static Date strToDate(String dateStr, String format) throws ParseException {
        return new SimpleDateFormat(format).parse(dateStr);
    }
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;
                    }
                }
            }
        }
    }
106840
@CheckForNull
  public static Date parseDateOrDateTime(@Nullable String stringDate) {
    if (stringDate == null) {
      return null;
    }

    OffsetDateTime odt = parseOffsetDateTimeQuietly(stringDate);
    if (odt != null) {
      return Date.from(odt.toInstant());
    }

    LocalDate ld = parseLocalDateQuietly(stringDate);
    checkArgument(ld != null, "Date '%s' cannot be parsed as either a date or date+time", stringDate);

    return Date.from(ld.atStartOfDay(ZoneId.systemDefault()).toInstant());
  }
376979
public static DateTime getDateTime(String strTime) {
        DateTime dateTime = null;
        if ((dateTime = tryFormat(strTime, dateTimeWithSubSecAndTZFormat)) == null) {
            if ((dateTime = tryFormat(strTime, dateTimeAndTZFormat)) == null) {
                if ((dateTime = tryFormat(strTime, dateTimeWithSubSecFormat)) == null) {
                    if ((dateTime = tryFormat(strTime, dateTimeFormat)) == null) {
                        if ((dateTime = tryFormat(strTime, dateHourMinOnlyFormat)) == null) {
                            if ((dateTime = tryFormat(strTime, dateHourOnlyFormat)) == null) {
                                if ((dateTime = tryFormat(strTime, dateTimeWithSubSecAndTZWithSpaceFormat)) == null) {
                                    if ((dateTime = tryFormat(strTime, dateTimeAndTZWithSpaceFormat)) == null) {
                                        if ((dateTime = tryFormat(strTime, dateTimeWithSubSecWithSpaceFormat)) == null) {
                                            if ((dateTime = tryFormat(strTime, dateTimeWithSpaceFormat)) == null) {
                                                if ((dateTime = tryFormat(strTime, dateHourMinWithSpaceOnlyFormat)) == null) {
                                                    if ((dateTime = tryFormat(strTime, dateHourWithSpaceOnlyFormat)) == null) {
                                                        if ((dateTime = tryFormat(strTime, dateOnlyFormat)) == null) {
                                                            if ((dateTime = tryFormat(strTime, yearMonthOnlyFormat)) == null) {
                                                                if ((dateTime = tryFormat(strTime, yearOnlyFormat)) == null) {
                                                                    return dateTime;
                                                                }
                                                            }
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
        return dateTime;
    }
474694
public static Date dateStringToDate(String dateString){
		SimpleDateFormat sdf=new SimpleDateFormat(DateTimeKit.FULL_DATE_24HR_STYLE);
		Date date = null;
		try {
			date = sdf.parse(dateString);
		} catch (ParseException e) {}  
		return date;
	}