### Question:
TimestampFinder { public Date findInString(String string) { for (Entry<SimpleDateFormat, Pattern> e : datePatternsByRegularExpressions.entrySet()) { Matcher matcher = e.getValue().matcher(string); if (matcher.find()) { String group = matcher.group(); Date timestamp = parseTimestamp(group, e.getKey()); if (timestamp != null) return timestamp; } } return null; } TimestampFinder(); Date findInString(String string);  }### Answer:
@Test public void testFindInString() throws Exception { TimestampFinder finder = new TimestampFinder(); assertEquals(utcTimestamp(2012, 05, 06, 22, 00), finder.findInString("N201205062200")); assertEquals(utcTimestamp(2012, 05, 06, 22, 00), finder.findInString("I201205062200")); assertEquals(utcTimestamp(2012, 05, 06, 22, 00), finder.findInString("R201205062200")); assertEquals(utcTimestamp(2012, 05, 06, 22, 00), finder.findInString("N20120506-2200")); assertEquals(utcTimestamp(2012, 05, 06, 22, 00), finder.findInString("I20120506-2200")); assertEquals(utcTimestamp(2012, 05, 06, 22, 00), finder.findInString("R20120506-2200")); assertEquals(utcTimestamp(2012, 05, 06, 00, 00), finder.findInString("N20120506")); assertEquals(utcTimestamp(2012, 05, 06, 00, 00), finder.findInString("I20120506")); assertEquals(utcTimestamp(2012, 05, 06, 00, 00), finder.findInString("R20120506")); assertEquals(utcTimestamp(2012, 05, 06, 22, 00), finder.findInString("v201205062200")); assertEquals(utcTimestamp(2012, 05, 06, 22, 00), finder.findInString("v20120506-2200")); assertEquals(utcTimestamp(2012, 05, 06, 22, 00), finder.findInString("20120506220000")); assertEquals(utcTimestamp(2012, 05, 06, 22, 00), finder.findInString("20120506-220000")); assertEquals(utcTimestamp(2012, 05, 06, 22, 00), finder.findInString("scdasdcasdc.sd0320-sdva-201205062200-dscsadvj0239inacslj")); }