@Test public void testCustomFormat() throws Exception { PrettyTime t = new PrettyTime(new Date(0)); t.setUnits( new TimeUnit() { public TimeFormat getFormat() { return new BasicTimeFormat() .setPattern("%n %u") .setRoundingTolerance(20) .setFutureSuffix("... RUN!") .setFuturePrefix("self destruct in: ") .setPastPrefix("self destruct was: ") .setPastSuffix(" ago..."); } public long getMaxQuantity() { return 0; } public long getMillisPerUnit() { return 5000; } public String getName() { return "tick"; } public String getPluralName() { return "ticks"; } }); assertEquals("self destruct in: 5 ticks ... RUN!", t.format(new Date(25000))); t.setReference(new Date(25000)); assertEquals("self destruct was: 5 ticks ago...", t.format(new Date(0))); }