### Question:
FileNamePattern extends ContextAwareBase { public String convert(Object o) { StringBuilder buf = new StringBuilder(); Converter<Object> p = headTokenConverter; while (p != null) { buf.append(p.convert(o)); p = p.getNext(); } return buf.toString(); } FileNamePattern(String patternArg, Context contextArg); String toString(); @Override int hashCode(); @Override boolean equals(Object obj); DateTokenConverter<Object> getPrimaryDateTokenConverter(); IntegerTokenConverter getIntegerTokenConverter(); boolean hasIntegerTokenCOnverter(); String convertMultipleArguments(Object... objectList); String convert(Object o); String convertInt(int i); void setPattern(String pattern); String getPattern(); String toRegexForFixedDate(Date date); String toRegex(); String toRegex(boolean capturePrimaryDate, boolean captureInteger);  }### Answer:
@Test public void date() { Calendar cal = Calendar.getInstance(); cal.set(2003, 4, 20, 17, 55); FileNamePattern pp = new FileNamePattern("foo%d{yyyy.MM.dd}", context); assertEquals("foo2003.05.20", pp.convert(cal.getTime())); pp = new FileNamePattern("foo%d{yyyy.MM.dd HH:mm}", context); assertEquals("foo2003.05.20 17:55", pp.convert(cal.getTime())); pp = new FileNamePattern("%d{yyyy.MM.dd HH:mm} foo", context); assertEquals("2003.05.20 17:55 foo", pp.convert(cal.getTime())); }
@Test public void dateWithTimeZone() { TimeZone utc = TimeZone.getTimeZone("UTC"); Calendar cal = Calendar.getInstance(utc); cal.set(2003, 4, 20, 10, 55); FileNamePattern fnp = new FileNamePattern("foo%d{yyyy-MM-dd'T'HH:mm, Australia/Perth}", context); assertEquals("foo2003-05-20T18:55", fnp.convert(cal.getTime())); }
@Test public void convertMultipleDates() { Calendar cal = Calendar.getInstance(); cal.set(2003, 4, 20, 17, 55); FileNamePattern fnp = new FileNamePattern("foo-%d{yyyy.MM, aux}/%d{yyyy.MM.dd}.txt", context); assertEquals("foo-2003.05/2003.05.20.txt", fnp.convert(cal.getTime())); }