@Test public void parsesRFC_1123() { String dateHeader = "Thu, 29 Dec 2011 12:03:50 GMT"; Date expectedDate = date(2011, 12, 29, 12, 3, 50, "GMT"); Date date = HeaderHelper.parseDateHeader(dateHeader); assertTrue(String.format("Dates are not equal, %s and %s", expectedDate, date), Math.abs(expectedDate.getTime() - date.getTime()) < 1000); }
public static Date parseDateHeader(String header) { for (SimpleDateFormat format : DateFormats.formats) { try { return ((SimpleDateFormat)format.clone()).parse(header); } catch (ParseException ignored) { } } throw new IllegalArgumentException(String.format("Not found appropriated date format for %s", header)); }
HeaderHelper { public static Date parseDateHeader(String header) { for (SimpleDateFormat format : DateFormats.formats) { try { return ((SimpleDateFormat)format.clone()).parse(header); } catch (ParseException ignored) { } } throw new IllegalArgumentException(String.format("Not found appropriated date format for %s", header)); } }
HeaderHelper { public static Date parseDateHeader(String header) { for (SimpleDateFormat format : DateFormats.formats) { try { return ((SimpleDateFormat)format.clone()).parse(header); } catch (ParseException ignored) { } } throw new IllegalArgumentException(String.format("Not found appropriated date format for %s", header)); } private  HeaderHelper(); }
HeaderHelper { public static Date parseDateHeader(String header) { for (SimpleDateFormat format : DateFormats.formats) { try { return ((SimpleDateFormat)format.clone()).parse(header); } catch (ParseException ignored) { } } throw new IllegalArgumentException(String.format("Not found appropriated date format for %s", header)); } private  HeaderHelper(); static List<AcceptMediaType> createAcceptMediaTypeList(String header); static List<AcceptLanguage> createAcceptedLanguageList(String header); static List<AcceptToken> createAcceptedCharsetList(String header); static List<AcceptToken> createAcceptedEncodingList(String header); static List<Cookie> parseCookies(String cookiesString); static NewCookie parseNewCookie(String newCookieString); static Date parseDateHeader(String header); static String formatDate(Date date); static long getContentLengthLong(MultivaluedMap<String, String> httpHeaders); @SuppressWarnings({"unchecked"}) static String getHeaderAsString(Object o); static String convertToString(Collection<String> collection); }
HeaderHelper { public static Date parseDateHeader(String header) { for (SimpleDateFormat format : DateFormats.formats) { try { return ((SimpleDateFormat)format.clone()).parse(header); } catch (ParseException ignored) { } } throw new IllegalArgumentException(String.format("Not found appropriated date format for %s", header)); } private  HeaderHelper(); static List<AcceptMediaType> createAcceptMediaTypeList(String header); static List<AcceptLanguage> createAcceptedLanguageList(String header); static List<AcceptToken> createAcceptedCharsetList(String header); static List<AcceptToken> createAcceptedEncodingList(String header); static List<Cookie> parseCookies(String cookiesString); static NewCookie parseNewCookie(String newCookieString); static Date parseDateHeader(String header); static String formatDate(Date date); static long getContentLengthLong(MultivaluedMap<String, String> httpHeaders); @SuppressWarnings({"unchecked"}) static String getHeaderAsString(Object o); static String convertToString(Collection<String> collection); static final Comparator<QualityValue> QUALITY_VALUE_COMPARATOR; }