### Question:
DateFormatCompiler { public TimestampFormat compile(CharSequence pattern) { return compile(pattern, false); } DateFormatCompiler(); TimestampFormat compile(CharSequence pattern); TimestampFormat compile(CharSequence pattern, boolean generic); TimestampFormat compile(CharSequence pattern, int lo, int hi, boolean generic);  }### Answer:
@Test public void testBasicParserCompiler() throws Exception { TimestampFormat fmt = compiler.compile("E, dd MMM yyyy a KK:m:s.S Z"); String utcPattern = "yyyy-MM-ddTHH:mm:ss.SSSz"; TimestampFormat utc = compiler.compile(utcPattern); long millis = fmt.parse("Mon, 08 Apr 2017 PM 11:11:10.123 UTC", defaultLocale); sink.clear(); utc.format(millis, defaultLocale, "Z", sink); TestUtils.assertEquals("2017-04-08T23:11:10.123Z", sink); }
@Test public void testNegativeYear() throws Exception { assertThat("yyyy MMM dd", "-2010-09-01T00:00:00.000Z", "-2010 Sep 01"); TimestampFormat fmt1 = compiler.compile("G yyyy MMM", true); TimestampFormat fmt2 = compiler.compile("yyyy MMM dd", true); long millis = fmt2.parse("-2010 Sep 01", defaultLocale); sink.clear(); fmt1.format(millis, defaultLocale, "Z", sink); TestUtils.assertEquals("BC -2010 Sep", sink); }
@Test(expected = BytecodeException.class) public void testLongPattern() { StringBuffer b = new StringBuffer(); for (int i = 0; i < 1000; i++) { b.append("KK").append(' ').append('Z').append(','); } compiler.compile(b); }