DurationFormatter { public String format(Instant instant) { return format(toDate(instant)); } private  DurationFormatter(Locale locale); static DurationFormatter forLocale(Locale locale); static DurationFormatter forRequestLocale(); String format(Instant instant); String format(LocalDateTime localDateTime); String format(Date date); String formatAsDays(Instant instant); String formatAsDays(Date date); String formatDifference(Instant instant); String formatDifference(LocalDateTime localDateTime); String formatDifference(Date date); String formatDifferenceAsDays(Instant instant); String formatDifferenceAsDays(Date date);  }
@Test public void format__givenDate__shouldFormatInLargestUnit() { assertEquals("Future format for seconds wrong", "1 minute from now", durationFormatter.format(inTwentySeconds)); assertEquals("Past format for seconds wrong", "1 minute ago", durationFormatter.format(twentySecondsAgo)); assertEquals("Future format for minutes wrong", "2 minutes from now", durationFormatter.format(inTwoMinutes)); assertEquals("Past format for minutes wrong", "2 minutes ago", durationFormatter.format(twoMinutesAgo)); assertEquals("Future format for hours wrong", "2 hours from now", durationFormatter.format(inTwoHours)); assertEquals("Past format for hours wrong", "2 hours ago", durationFormatter.format(twoHoursAgo)); assertEquals("Future format for days wrong", "2 days from now", durationFormatter.format(inTwoDays)); assertEquals("Past format for days wrong", "2 days ago", durationFormatter.format(twoDaysAgo)); assertEquals("Future format for months wrong", "2 months from now", durationFormatter.format(inTwoMonths)); assertEquals("Past format for months wrong", "2 months ago", durationFormatter.format(twoMonthsAgo)); }