Returns a Java representation of a {@code date} string.

@param date
Date in string format.
@return Java date representation of the given {@code date} string or {@code null} if {@code date} is {@code null}
or invalid.
18859
private static Date toDateWithFormatString(String date, String format) {
    if (date == null) {
      return null;
    }

    try {
      return strategy.formatFor(format).parse(date);
    } catch (ParseException e) {
      UTILS_LOGGER.trace("Unable to parse date '{}' using format string '{}': {}", date, format, e);

      return null;
    }
  }
194030
public static String formatDate(Date date) {
        return org.apache.http.client.utils.DateUtils.formatDate(date);
    }
284686
public static String getDateString(String format, Date date) {
        SimpleDateFormat sdf = new SimpleDateFormat(format);
        return sdf.format(date);
    }
1083260
@SuppressWarnings("unchecked")
    public T date( Date... date ) {
        if (checkIfNull(date)) {
            return (T) this;
        }
        date = ensureDateNotTimestamp(date);
        addObjectParameter(DATE_LIST, "date", date);
        return (T) this;
    }
177062
@Override
    public String format(Date date, String mask) {
	return format(date, mask, null);
    }
640905
public static String convertDateToTimeString(Date date) {
		if (date == null) {
			return null;
		} else {
			// DateFormat df = new SimpleDateFormat("HH:mm:ss.SSS'Z'");
			DateTimeFormatter df = FORMATTER_SECONDS_Z;
			return df.print(date.getTime());
		}
	}
745127
public String quote (Date date)
    {
        return (date == null) ? null : escape(String.valueOf(date));
    }
1351580
public static String formatDateTime(Date date) {
		if (null == date) {
			return null;
		}
		return DatePattern.NORM_DATETIME_FORMAT.format(date);
	}
1143524
public static String format(String pattern, Date date) {
	synchronized (data) {
	    Object obj = data.get(pattern);
	    if (obj != null) {
		return ((SimpleDateFormat) obj).format(date);
	    } // print.ln(pattern);
	    SimpleDateFormat sdf = new SimpleDateFormat(pattern);
	    data.put(pattern, sdf);
	    return sdf.format(date);
	}
    }
1347946
public static String encodeDate(Date date) {
		SimpleDateFormat dateFormatter = new SimpleDateFormat(dateFormat);
		dateFormatter.setTimeZone(TimeZone.getTimeZone(UTC_TZ_ID));
		/* Java doesn't handle ISO8601 nicely: need to add ':' manually */
		String result = dateFormatter.format(date);
		return result.substring(0, result.length() - ENCODE_DATE_COLONS_INDEX) + ":"
				+ result.substring(result.length() - ENCODE_DATE_COLONS_INDEX);
	}
157893
public static Date parseAWSDate(String date) {
		if (date == null) {
			return null;
		}
		return TIME_FORMATTER.parseDateTime(date).toDate();
	}
761192
public static String getDateStr(Date date) {
        java.text.SimpleDateFormat sdf = new java.text.SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        return sdf.format(date);
    }
83708
public static Date fromJavaUtilDate(java.util.Date date) {
    Calendar cal = Calendar.getInstance();
    cal.setTime(date);
    cal.set(Calendar.HOUR_OF_DAY, 0);
    cal.set(Calendar.MINUTE, 0);
    cal.set(Calendar.SECOND, 0);
    cal.set(Calendar.MILLISECOND, 0);
    // Calender.MONTH starts from 0 while G C date starts from 1
    return new Date(
        cal.get(Calendar.YEAR), cal.get(Calendar.MONTH) + 1, cal.get(Calendar.DAY_OF_MONTH));
  }
871719
public static String getFormattedObect(String date)
    {
        return date != null ? getDateByPattern(date).toString() : null;
    }
85996
public static CharSequence getJSDate(Date date)
	{
		Calendar calendar = Calendar.getInstance();
		calendar.setTime(date);

		return getJSDate(calendar);
	}
690945
public static String format(Date date) {
        String format = LOCAL_DATE_FORMAT.format(date);
        // Java 6 does not have a convenient way of having the colon in the timezone offset
        return format.substring(0,22) + ":" + format.substring(22);
    }
742754
public Date toDate(Object date) {

        Date d = null;
        if (null != date) {
            if (date instanceof Date) {
                d = (Date)date;
            } else if (date instanceof Long) {
                d = new Date(((Long)date).longValue());
            } else {
                try {
                    long l = Long.parseLong(date.toString());
                    d = new Date(l);
                } catch (Exception e) {
                    // do nothing, just let d remain null
                }
            }
        }
        return d;
    }