DefaultHttpHeaderManager implements HttpHeaderManager { @Override public long getDateHeader(String name) throws IllegalArgumentException { long result = -1; if (headers.containsKey(name.toUpperCase(locale))) { DefaultHttpHeader header = headers.get(name.toUpperCase(locale)); try { String value = header.getValue(); SimpleDateFormat format = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss zzz"); result = format.parse(value).getTime(); } catch (ParseException exception) { throw new IllegalArgumentException( "Cannot convert header to a date", exception); } } return result; } DefaultHttpHeaderManager(); @Override void addHeader(String name, String value); @Override boolean containsHeader(String name); @Override long getDateHeader(String name); @Override String getHeader(String name); @Override Enumeration<String> getHeaderNames(); @Override Enumeration<String> getHeaders(String name); @Override int getIntHeader(String name); @Override void setHeader(String name, String value);  }
@Test void testGetDateHeader() { DefaultHttpHeaderManager manager = new DefaultHttpHeaderManager(); SimpleDateFormat format = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss zzz"); manager.addHeader("NAME", format.format(new Date())); assertTrue(manager.getDateHeader("NAME") > 0); }
@Test void testGetDateHeader2() { DefaultHttpHeaderManager manager = new DefaultHttpHeaderManager(); assertEquals(-1, manager.getDateHeader("NAME")); }