### Question:
DateUtils { public static String toHuman(long duration) { StringBuffer res = new StringBuffer(); long temp = 0; if (duration >= ONE_SECOND) { temp = duration / ONE_DAY; if (temp > 0) { duration -= temp * ONE_DAY; res.append(temp).append(" day").append(temp > 1 ? "s" : "") .append(duration >= ONE_MINUTE ? ", " : ""); } temp = duration / ONE_HOUR; if (temp > 0) { duration -= temp * ONE_HOUR; res.append(temp).append(" hour").append(temp > 1 ? "s" : "") .append(duration >= ONE_MINUTE ? ", " : ""); } temp = duration / ONE_MINUTE; if (temp > 0) { duration -= temp * ONE_MINUTE; res.append(temp).append(" minute").append(temp > 1 ? "s" : ""); } if (!res.toString().equals("") && duration >= ONE_SECOND) { res.append(" and "); } temp = duration / ONE_SECOND; if (temp > 0) { res.append(temp).append(" second").append(temp > 1 ? "s" : ""); } return res.toString(); } else { return "0 second"; } }  static String toHuman(long duration); static String nowToHuman(); final static long ONE_SECOND; final static long SECONDS; final static long ONE_MINUTE; final static long MINUTES; final static long ONE_HOUR; final static long HOURS; final static long ONE_DAY; static final String DATE_FORMAT_NOW; }### Answer:
@Test public void test() { assertEquals("0 second", toHuman(123)); assertEquals("5 seconds", toHuman((5 * ONE_SECOND) + 123)); assertEquals("1 day, 1 hour", toHuman(ONE_DAY + ONE_HOUR)); assertEquals("1 day and 2 seconds", toHuman(ONE_DAY + 2 * ONE_SECOND)); assertEquals("1 day, 1 hour, 2 minutes", toHuman(ONE_DAY + ONE_HOUR + (2 * ONE_MINUTE))); assertEquals("4 days, 3 hours, 2 minutes and 1 second", toHuman((4 * ONE_DAY) + (3 * ONE_HOUR) + (2 * ONE_MINUTE) + ONE_SECOND)); assertEquals("5 days, 4 hours, 1 minute and 23 seconds", toHuman((5 * ONE_DAY) + (4 * ONE_HOUR) + ONE_MINUTE + (23 * ONE_SECOND) + 123)); assertEquals("42 days", toHuman(42 * ONE_DAY)); }