DateFormatter { public static Date parseHttpDate(CharSequence txt) { return parseHttpDate(txt, 0, txt.length()); } private  DateFormatter(); static Date parseHttpDate(CharSequence txt); static Date parseHttpDate(CharSequence txt, int start, int end); static String format(Date date); static StringBuilder append(Date date, StringBuilder sb); void reset();  }
@Test public void testParseWithSingleDigitDay() { assertEquals(DATE, parseHttpDate("Sun, 6 Nov 1994 08:49:37 GMT")); }
@Test public void testParseWithDoubleDigitDay() { assertEquals(DATE, parseHttpDate("Sun, 06 Nov 1994 08:49:37 GMT")); }
@Test public void testParseWithDashSeparatorSingleDigitDay() { assertEquals(DATE, parseHttpDate("Sunday, 06-Nov-94 08:49:37 GMT")); }
@Test public void testParseWithSingleDoubleDigitDay() { assertEquals(DATE, parseHttpDate("Sunday, 6-Nov-94 08:49:37 GMT")); }
@Test public void testParseWithoutGMT() { assertEquals(DATE, parseHttpDate("Sun Nov 6 08:49:37 1994")); }
@Test public void testParseWithFunkyTimezone() { assertEquals(DATE, parseHttpDate("Sun Nov 6 08:49:37 1994 -0000")); }
@Test public void testParseWithSingleDigitHourMinutesAndSecond() { assertEquals(DATE, parseHttpDate("Sunday, 6-Nov-94 8:49:37 GMT")); }
@Test public void testParseWithSingleDigitTime() { assertEquals(DATE, parseHttpDate("Sunday, 6 Nov 1994 8:49:37 GMT")); Date _08_09_37 = new Date(TIMESTAMP - 40 * 60 * 1000); assertEquals(_08_09_37, parseHttpDate("Sunday, 6 Nov 1994 8:9:37 GMT")); assertEquals(_08_09_37, parseHttpDate("Sunday, 6 Nov 1994 8:09:37 GMT")); Date _08_09_07 = new Date(TIMESTAMP - (40 * 60 + 30) * 1000); assertEquals(_08_09_07, parseHttpDate("Sunday, 6 Nov 1994 8:9:7 GMT")); assertEquals(_08_09_07, parseHttpDate("Sunday, 6 Nov 1994 8:9:07 GMT")); }
@Test public void testParseMidnight() { assertEquals(new Date(784080000000L), parseHttpDate("Sunday, 6 Nov 1994 00:00:00 GMT")); }
@Test public void testParseInvalidInput() { assertNull(parseHttpDate("Sun, Nov 1994 08:49:37 GMT")); assertNull(parseHttpDate("Sun, 6 1994 08:49:37 GMT")); assertNull(parseHttpDate("Sun, 6 Nov 08:49:37 GMT")); assertNull(parseHttpDate("Sun, 6 Nov 1994 :49:37 GMT")); assertNull(parseHttpDate("Sun, 6 Nov 1994 49:37 GMT")); assertNull(parseHttpDate("Sun, 6 Nov 1994 08::37 GMT")); assertNull(parseHttpDate("Sun, 6 Nov 1994 08:37 GMT")); assertNull(parseHttpDate("Sun, 6 Nov 1994 08:49: GMT")); assertNull(parseHttpDate("Sun, 6 Nov 1994 08:49 GMT")); assertNull(parseHttpDate("Sun, 6 FOO 1994 08:49:37 GMT")); assertNull(parseHttpDate("Sun, 36 Nov 1994 08:49:37 GMT")); assertNull(parseHttpDate("Sun, 6 Nov 1994 28:49:37 GMT")); assertNull(parseHttpDate("Sun, 6 Nov 1994 08:69:37 GMT")); assertNull(parseHttpDate("Sun, 6 Nov 1994 08:49:67 GMT")); assertNull(parseHttpDate("Sunday, 6 Nov 1994 0:0:000 GMT")); assertNull(parseHttpDate("Sunday, 6 Nov 1994 0:000:0 GMT")); assertNull(parseHttpDate("Sunday, 6 Nov 1994 000:0:0 GMT")); }