### Question:
RelativeDateFormat extends DateFormat { @Override public StringBuffer format(Date date, StringBuffer toAppendTo, FieldPosition fieldPosition) { long currentMillis = date.getTime(); long elapsed = currentMillis - this.baseMillis; String signPrefix; if (elapsed < 0) { elapsed *= -1L; signPrefix = "-"; } else { signPrefix = this.positivePrefix; } long days = elapsed / MILLISECONDS_IN_ONE_DAY; elapsed = elapsed - (days * MILLISECONDS_IN_ONE_DAY); long hours = elapsed / MILLISECONDS_IN_ONE_HOUR; elapsed = elapsed - (hours * MILLISECONDS_IN_ONE_HOUR); long minutes = elapsed / 60000L; elapsed = elapsed - (minutes * 60000L); double seconds = elapsed / 1000.0; toAppendTo.append(signPrefix); if (days != 0 || this.showZeroDays) { toAppendTo.append(this.dayFormatter.format(days) + getDaySuffix()); } if (hours != 0 || this.showZeroHours) { toAppendTo.append(this.hourFormatter.format(hours) + getHourSuffix()); } toAppendTo.append(this.minuteFormatter.format(minutes) + getMinuteSuffix()); toAppendTo.append(this.secondFormatter.format(seconds) + getSecondSuffix()); return toAppendTo; } RelativeDateFormat();  RelativeDateFormat(Date time);  RelativeDateFormat(long baseMillis); long getBaseMillis(); void setBaseMillis(long baseMillis); boolean getShowZeroDays(); void setShowZeroDays(boolean show); boolean getShowZeroHours(); void setShowZeroHours(boolean show); String getPositivePrefix(); void setPositivePrefix(String prefix); void setDayFormatter(NumberFormat formatter); String getDaySuffix(); void setDaySuffix(String suffix); void setHourFormatter(NumberFormat formatter); String getHourSuffix(); void setHourSuffix(String suffix); void setMinuteFormatter(NumberFormat formatter); String getMinuteSuffix(); void setMinuteSuffix(String suffix); String getSecondSuffix(); void setSecondSuffix(String suffix); void setSecondFormatter(NumberFormat formatter); @Override StringBuffer format(Date date, StringBuffer toAppendTo,
                               FieldPosition fieldPosition); @Override Date parse(String source, ParsePosition pos); @Override boolean equals(Object obj); @Override int hashCode(); @Override Object clone(); static void main(String[] args);  }### Answer:
@Test public void testFormat() { RelativeDateFormat rdf = new RelativeDateFormat(); String s = rdf.format(new Date(2 * 60L * 60L * 1000L + 122500L)); assertEquals("2h2m2.500s", s); }