### Question:
DateParser { static ExtractedDate findRelativeDate(String text, long currentTime) { ExtractedDate date = null; for (DateFormat dateFormat : RegExp.RELATIVE_DATES) { Pattern pattern = dateFormat.getPattern(); Matcher matcher = pattern.matcher(text); if (matcher.find()) { String relativeTime = matcher.group(); long number = Long.parseLong(relativeTime.split(" ")[0]); String format = dateFormat.getFormat(); long diffTime = 0; if (format.equalsIgnoreCase("min")) { diffTime = TimeUnit.MINUTES.toMillis(number); } else if (format.equalsIgnoreCase("hour")) { diffTime = TimeUnit.HOURS.toMillis(number); } else if (format.equalsIgnoreCase("day")) { diffTime = TimeUnit.DAYS.toMillis(number); } else if (format.equalsIgnoreCase("mon")) { diffTime = number * 30 * 24 * 60 * 60 * 1000; } else if (format.equalsIgnoreCase("year")) { diffTime = number * 365 * 24 * 60 * 60 * 1000; } long relTime = currentTime - diffTime; date = new ExtractedDateImpl(relTime); break; } } return date; } private  DateParser(); static ExtractedDate parseDate(String date); static ExtractedDate parseDateWithTimeZone(String date, String timeZone); static ExtractedDate parseDate(String date, DateFormat format); static ExtractedDate parseDate(String date, DateFormat format, String timeZone); static ExtractedDate findDate(String text); static ExtractedDate findDate(String text, DateFormat... formats); static ExtractedDate findDate(String text, DateFormat format); static List<ExtractedDate> findDates(String text); static List<ExtractedDate> findDates(String text, DateFormat... formats); static List<ExtractedDate> findDates(String text, DateFormat format); static ExtractedDate findRelativeDate(String text);  }### Answer:
@Test public void testFindRelativeDate() { long currentTime = 1291201200000l; ExtractedDate relDate = DateParser.findRelativeDate("5 days ago", currentTime); assertEquals("2010-11-26", relDate.getNormalizedDateString(false)); relDate = DateParser.findRelativeDate("114 days ago", currentTime); assertEquals("2010-08-09", relDate.getNormalizedDateString(false)); relDate = DateParser.findRelativeDate("4 month ago", currentTime); assertEquals("2010-08-03", relDate.getNormalizedDateString(false)); relDate = DateParser.findRelativeDate("12 month ago", currentTime); assertEquals("2009-12-06", relDate.getNormalizedDateString(false)); relDate = DateParser.findRelativeDate("1 year ago", currentTime); assertEquals("2009-12-01", relDate.getNormalizedDateString(false)); relDate = DateParser.findRelativeDate("11 years ago", currentTime); assertEquals("1999-12-04", relDate.getNormalizedDateString(false)); relDate = DateParser.findRelativeDate("1 minute ago", currentTime); assertEquals("2010-12-01", relDate.getNormalizedDateString(false)); }