HttpHeadersImpl implements HttpHeaders { @Override public Date getDate() { String value = nettyHttpHeaders.get(HttpHeaders.DATE); if (value == null || value.isEmpty()) { return null; } SimpleDateFormat dateFormat = new SimpleDateFormat(DATE_FORMAT_PATTERN, Locale.ENGLISH); dateFormat.setTimeZone(TimeZone.getTimeZone(GMT_TIMEZONE)); try { return dateFormat.parse(value); } catch (ParseException e) { log.error("Error while parsing the Date value. Hence return null", e); return null; } } HttpHeadersImpl(io.netty.handler.codec.http.HttpHeaders httpHeaders); @Override List<String> getRequestHeader(String name); @Override String getHeaderString(String name); @Override MultivaluedMap<String, String> getRequestHeaders(); @Override List<MediaType> getAcceptableMediaTypes(); @Override List<Locale> getAcceptableLanguages(); @Override MediaType getMediaType(); @Override Locale getLanguage(); @Override Map<String, Cookie> getCookies(); @Override Date getDate(); @Override int getLength();  }
@Test public void testGetDate() throws Exception { Date date = httpHeaders1.getDate(); assertNotNull(date); assertEquals(date.getTime(), 784111777000L); Date date2 = httpHeaders2.getDate(); assertNull(date2); }