/** * 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 * * @throws DateParseException if none of the dataFormats could parse the dateValue */ public static Date parseDate(final String dateValue, String[] dateFormats) throws DateParseException { 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 * * @throws DateParseException if the value could not be parsed using any of the * supported date formats */ public static Date parseDate(String dateValue) throws DateParseException { return parseDate(dateValue, null, null); }
/** * Parse date in RFC1123 format, and return its value as epoch */ public static long parseDateAsEpoch(String dateStr) { try { // Parse date in RFC1123 format if this header contains one return DateUtils.parseDate(dateStr).getTime(); } catch (DateParseException e) { // Date in invalid format, fallback to 0 return 0; } }
/** * Parse date in RFC1123 format, and return its value as epoch */ public static long parseDateAsEpoch(String dateStr) { try { // Parse date in RFC1123 format if this header contains one return DateUtils.parseDate(dateStr).getTime(); } catch (DateParseException e) { // Date in invalid format, fallback to 0 return 0; } }
/** * Parse date in RFC1123 format, and return its value as epoch */ public static long parseDateAsEpoch(String dateStr) { try { // Parse date in RFC1123 format if this header contains one return DateUtils.parseDate(dateStr).getTime(); } catch (DateParseException e) { // Date in invalid format, fallback to 0 return 0; } }
public void parse(final SetCookie cookie, final String value) throws MalformedCookieException { if (cookie == null) { throw new IllegalArgumentException("Cookie may not be null"); } if (value == null) { throw new MalformedCookieException("Missing value for expires attribute"); } try { cookie.setExpiryDate(DateUtils.parseDate(value, this.datepatterns)); } catch (DateParseException dpe) { throw new MalformedCookieException("Unable to parse expires attribute: " + value); } }
DateUtils.parseDate(headervalue.substring(i1, i2), this.datepatterns); isNetscapeCookie = true; } catch (DateParseException e) {
/** * Parse date in RFC1123 format, and return its value as epoch */ public static long parseDateAsEpoch(String dateStr) { try { // Parse date in RFC1123 format if this header contains one return DateUtils.parseDate(dateStr).getTime(); } catch (DateParseException e) { // Date in invalid format, fallback to 0 return 0; } }
/** * Parse date in RFC1123 format, and return its value as epoch */ public static long parseDateAsEpoch(String dateStr) { try { // Parse date in RFC1123 format if this header contains one return org.apache.http.impl.cookie.DateUtils.parseDate(dateStr).getTime(); } catch (DateParseException e) { // Date in invalid format, fallback to 0 return 0; } }
/** * Parse date in RFC1123 format, and return its value as epoch */ public static long parseDateAsEpoch(String dateStr) { try { // Parse date in RFC1123 format if this header contains one return DateUtils.parseDate(dateStr).getTime(); } catch (DateParseException e) { // Date in invalid format, fallback to 0 return 0; } }
/** * Parse date in RFC1123 format, and return its value as epoch */ public static long parseDateAsEpoch(String dateStr) { try { // Parse date in RFC1123 format if this header contains one return DateUtils.parseDate(dateStr).getTime(); } catch (DateParseException e) { // Date in invalid format, fallback to 0 return 0; } }
/** * Parse date in RFC1123 format, and return its value as epoch */ public static long parseDateAsEpoch(String dateStr) { try { // Parse date in RFC1123 format if this header contains one return DateUtils.parseDate(dateStr).getTime(); } catch (DateParseException e) { // Date in invalid format, fallback to 0 return 0; } }
/** * Parse date in RFC1123 format, and return its value as epoch */ public static long parseDateAsEpoch(String dateStr) { try { // Parse date in RFC1123 format if this header contains one return DateUtils.parseDate(dateStr).getTime(); } catch (DateParseException e) { // Date in invalid format, fallback to 0 return 0; } }
public Date getExpires() { Header expiresHeader = resp.getFirstHeader("Expires"); if (expiresHeader == null) return null; try { return DateUtils.parseDate(expiresHeader.getValue()); } catch (DateParseException e) { log.warn("error while parsing Expires header", e); return null; } }
protected void consumeWarnDate() { int curr = offs; Matcher m = WARN_DATE_PATTERN.matcher(src.substring(offs)); if (!m.lookingAt()) parseError(); offs += m.end(); try { warnDate = DateUtils.parseDate(src.substring(curr+1,offs-1)); } catch (DateParseException e) { throw new IllegalStateException("couldn't parse a parseable date"); } }
public Date asDate(String name) { String str = all(name); if (str == null) { return null; } try { return DateUtils.parseDate(str); } catch (DateParseException e) { throw new RuntimeException(e); } } }
private Date getExpiresDate() { String expires = get("Expires", this.response); try { return DateUtils.parseDate(expires); } catch(Exception e) { // if not present or parsable... just ignore return OLD; } }
protected Date getDateValue(final HttpCacheEntry entry) { Header dateHdr = entry.getFirstHeader(HTTP.DATE_HEADER); if (dateHdr == null) return null; try { return DateUtils.parseDate(dateHdr.getValue()); } catch (DateParseException dpe) { // ignore malformed date } return null; }
protected Date getLastModifiedValue(final HttpCacheEntry entry) { Header dateHdr = entry.getFirstHeader(HeaderConstants.LAST_MODIFIED); if (dateHdr == null) return null; try { return DateUtils.parseDate(dateHdr.getValue()); } catch (DateParseException dpe) { // ignore malformed date } return null; }
protected Date getExpirationDate(final HttpCacheEntry entry) { Header expiresHeader = entry.getFirstHeader(HeaderConstants.EXPIRES); if (expiresHeader == null) return null; try { return DateUtils.parseDate(expiresHeader.getValue()); } catch (DateParseException dpe) { // malformed expires header } return null; }