/** * Parse the string to date * * @param date to parse. Accepted formats are yyyyMMddHHmm and yyyyMMdd * @return the parsed date or null if input could not be parsed */ public static Date getDate(String date) { if (StringUtils.isEmpty(date)) return null; return DateUtils.parseDate(date, patterns); }
/** * Parses a date value. The formats used for parsing the date value are retrieved from * the default http params. * * @param dateValue the date value to parse * * @return the parsed date or null if input could not be parsed */ public static Date parseDate(final String dateValue) { return parseDate(dateValue, null, null); }
/** * Parses a date value. The formats used for parsing the date value are retrieved from * the default http params. * * @param dateValue the date value to parse * * @return the parsed date or null if input could not be parsed */ public static Date parseDate(final String dateValue) { return parseDate(dateValue, null, null); }
/** * Parses the date value using the given date formats. * * @param dateValue the date value to parse * @param dateFormats the date formats to use * * @return the parsed date or null if input could not be parsed */ public static Date parseDate(final String dateValue, final String[] dateFormats) { return parseDate(dateValue, dateFormats, null); }
/** * Parses a date value. The formats used for parsing the date value are retrieved from * the default http params. * * @param dateValue the date value to parse * * @return the parsed date or null if input could not be parsed */ public static Date parseDate(final String dateValue) { return parseDate(dateValue, null, null); }
/** * Parses a date value. The formats used for parsing the date value are retrieved from * the default http params. * * @param dateValue the date value to parse * * @return the parsed date or null if input could not be parsed */ public static Date parseDate(final String dateValue) { return parseDate(dateValue, null, null); }
/** * Parses the date value using the given date formats. * * @param dateValue the date value to parse * @param dateFormats the date formats to use * * @return the parsed date or null if input could not be parsed */ public static Date parseDate(final String dateValue, final String[] dateFormats) { return parseDate(dateValue, dateFormats, null); }
/** * Parses the date value using the given date formats. * * @param dateValue the date value to parse * @param dateFormats the date formats to use * * @return the parsed date or null if input could not be parsed */ public static Date parseDate(final String dateValue, final String[] dateFormats) { return parseDate(dateValue, dateFormats, null); }
/** * Parses a date value. The formats used for parsing the date value are retrieved from * the default http params. * * @param dateValue the date value to parse * * @return the parsed date or null if input could not be parsed */ public static Date parseDate(final String dateValue) { return parseDate(dateValue, null, null); }
private long parseStringDate(String value) { Date date = DateUtils.parseDate(value); if (date == null) { throw new IllegalStateException("Could not parse Last-Modified header with value " + value); } return date.getTime(); }
private static DateTime parseDateTime(final String stringValue) { if (!Strings.isNullOrEmpty(stringValue)) { final Date date = DateUtils.parseDate(stringValue); if (date != null) { return new DateTime(date.getTime()); } } return null; } }
private long getLastModified(HttpResponse response) { Header last = response.getLastHeader("Last-Modified"); if (last == null) { return -1; } else { return DateUtils.parseDate(last.getValue()).getTime(); } }
protected Date getLastModifiedValue(final HttpCacheEntry entry) { final Header dateHdr = entry.getFirstHeader(HeaderConstants.LAST_MODIFIED); if (dateHdr == null) { return null; } return DateUtils.parseDate(dateHdr.getValue()); }
protected Date getExpirationDate(final HttpCacheEntry entry) { final Header expiresHeader = entry.getFirstHeader(HeaderConstants.EXPIRES); if (expiresHeader == null) { return null; } return DateUtils.parseDate(expiresHeader.getValue()); }
private long getLastModified(HttpResponse response) { Header last = response.getLastHeader("Last-Modified"); if (last == null) { return -1; } else { return DateUtils.parseDate(last.getValue()).getTime(); } }
/** {@inheritDoc} */ @Override public long lastModified() throws IOException { final String response = getResponseHeader(HttpHeaders.LAST_MODIFIED); if (null != response) { return DateUtils.parseDate(response).getTime(); } final String errMsg = "Response from remote resource " + resourceURL.toString() + " did not contain a Last-Modified header"; log.error(errMsg); throw new IOException(errMsg); }
protected void consumeWarnDate() { final int curr = offs; final Matcher m = WARN_DATE_PATTERN.matcher(src.substring(offs)); if (!m.lookingAt()) { parseError(); } offs += m.end(); warnDate = DateUtils.parseDate(src.substring(curr+1,offs-1)); }
private boolean hasValidDateField(final HttpRequest request, final String headerName) { for(final Header h : request.getHeaders(headerName)) { final Date date = DateUtils.parseDate(h.getValue()); return date != null; } return false; } }
private long lastModified(HttpResponse httpResponse) { String date = getHeader(httpResponse, "Last-modified", null); if (date == null) { date = getHeader(httpResponse, "Date", null); } Date dt = DateUtils.parseDate(date); return dt.getTime(); }
private long lastModified(HttpResponse httpResponse) { String date = getHeader(httpResponse, "Last-modified", null); if (date == null) { date = getHeader(httpResponse, "Date", null); } Date dt = DateUtils.parseDate(date); return dt.getTime(); }