PrettyTime { public PrettyTime setLocale(Locale locale) { if (locale == null) locale = Locale.getDefault(); this.locale = locale; for (TimeUnit unit : units.keySet()) { if (unit instanceof LocaleAware) ((LocaleAware<?>) unit).setLocale(locale); } for (TimeFormat format : units.values()) { if (format instanceof LocaleAware) ((LocaleAware<?>) format).setLocale(locale); } cachedUnits = null; return this; } PrettyTime();  PrettyTime(String overrideResourceBundle);  PrettyTime(final Date reference);  PrettyTime(final Date reference, String overrideResourceBundle);  PrettyTime(final Locale locale);  PrettyTime(final Locale locale, String overrideResourceBundle);  PrettyTime(final Date reference, final Locale locale);  PrettyTime(final Date reference, final Locale locale, String overrideResourceBundle); Duration approximateDuration(Date then); List<Duration> calculatePreciseDuration(Date then); String format(Date then); String format(Calendar then); String format(final Duration duration); String format(final List<Duration> durations); String formatUnrounded(Date then); String formatUnrounded(Calendar then); String formatUnrounded(Duration duration); String formatUnrounded(List<Duration> durations); String formatDuration(Date then); String formatDuration(Calendar then); String formatDuration(Duration duration); String formatDuration(final List<Duration> durations); String formatDurationUnrounded(Date then); String formatDurationUnrounded(Calendar then); String formatDurationUnrounded(Duration duration); String formatDurationUnrounded(final List<Duration> durations); TimeFormat getFormat(TimeUnit unit); Date getReference(); PrettyTime setReference(final Date timestamp); List<TimeUnit> getUnits(); @SuppressWarnings("unchecked") UNIT getUnit(final Class<UNIT> unitType); PrettyTime registerUnit(final TimeUnit unit, TimeFormat format); TimeFormat removeUnit(final Class<UNIT> unitType); TimeFormat removeUnit(final TimeUnit unit); Locale getLocale(); PrettyTime setLocale(Locale locale); @Override String toString(); List<TimeUnit> clearUnits();  }
@Test public void testSetLocale() throws Exception { PrettyTime t = new PrettyTime(new Date(315569259747L * 3L)); Assert.assertEquals("3 decades ago", t.format(new Date(0))); t.setLocale(Locale.GERMAN); Assert.assertEquals("vor 3 Jahrzehnten", t.format(new Date(0))); }