@Test(threadPoolSize = 10, invocationCount = 10) public void naturalTimeTest() { assertTrue(naturalTime(new Date(0), new Date(10)).endsWith(" from now")); assertEquals(naturalTime(new Date(0), new Date(1000 * 60 * 12)), "12 minutes from now"); assertEquals(naturalTime(new Date(0), new Date(1000 * 60 * 60 * 3)), "3 hours from now"); assertEquals(naturalTime(new Date(0), new Date(1000 * 60 * 60 * 24 * 1)), "1 day from now"); assertEquals(naturalTime(new Date(0), new Date(1000 * 60 * 60 * 24 * 3)), "3 days from now"); assertEquals(naturalTime(new Date(0), new Date(1000 * 60 * 60 * 24 * 7 * 3)), "3 weeks from now"); assertEquals(naturalTime(new Date(0), new Date(2629743830L * 3L)), "2 months from now"); assertEquals(naturalTime(new Date(0), new Date(2629743830L * 13L * 3L)), "3 years from now"); assertEquals(naturalTime(new Date(0), new Date(315769289947L * 3L)), "30 years from now"); assertEquals(naturalTime(new Date(0), new Date(3155792597470L * 3L)), "300 years from now"); assertEquals(naturalTime(new Date(6000), new Date(0)), "6 seconds ago"); assertEquals(naturalTime(new Date(1000 * 60 * 12), new Date(0)), "12 minutes ago"); assertEquals(naturalTime(new Date(1000 * 60 * 60 * 3), new Date(0)), "3 hours ago"); assertEquals(naturalTime(new Date(1000 * 60 * 60 * 24 * 1), new Date(0)), "1 day ago"); assertEquals(naturalTime(new Date(1000 * 60 * 60 * 24 * 3), new Date(0)), "3 days ago"); assertEquals(naturalTime(new Date(1000 * 60 * 60 * 24 * 7 * 3), new Date(0)), "3 weeks ago"); assertEquals(naturalTime(new Date(2629743830L * 3L), new Date(0)), "2 months ago"); assertEquals(naturalTime(new Date(2629743830L * 13L * 3L), new Date(0)), "3 years ago"); assertEquals(naturalTime(new Date(315769289947L * 3L), new Date(0)), "30 years ago"); assertEquals(naturalTime(new Date(3155792597470L * 3L), new Date(0)), "300 years ago"); assertTrue(naturalTime(new Date(0), new Date(10), ES).startsWith("dentro de")); assertEquals(naturalTime(new Date(0), new Date(1000 * 60 * 60 * 3), ES), "dentro de 3 horas"); assertEquals(naturalTime(new Date(0), new Date(1000 * 60 * 60 * 24 * 1), ES), "dentro de un día"); assertEquals(naturalTime(new Date(315769289947L * 3L), new Date(0), ES), "hace 30 años"); assertEquals(naturalTime(new Date(3155792597470L * 3L), new Date(0), ES), "hace 300 años"); }
public static String naturalTime(final Date duration) { return context.get().getDurationFormat().formatDurationFromNowTo(duration); }
ICUHumanize { public static String naturalTime(final Date duration) { return context.get().getDurationFormat().formatDurationFromNowTo(duration); } }
ICUHumanize { public static String naturalTime(final Date duration) { return context.get().getDurationFormat().formatDurationFromNowTo(duration); } private  ICUHumanize(); }
ICUHumanize { public static String naturalTime(final Date duration) { return context.get().getDurationFormat().formatDurationFromNowTo(duration); } private  ICUHumanize(); static String compactDecimal(final Number value); static String compactDecimal(final Number value, final CompactStyle style); static String compactDecimal(final Number value, final CompactStyle style, final Locale locale); static String compactDecimal(final Number value, final Locale locale); static DateFormat dateFormatInstance(final String pattern); static DateFormat dateFormatInstance(final String pattern, final Locale locale); static DecimalFormat decimalFormatInstance(final String pattern); static DecimalFormat decimalFormatInstance(final String pattern, final Locale locale); static String duration(final Number value); static String format(final String pattern, final Object... args); static String formatCurrency(final Number value); static String formatCurrency(final Number value, final Locale locale); static String formatDate(final Date value); static String formatDate(final Date value, final Locale locale); static String formatDate(final Date value, final String pattern); static String formatDate(final Date value, final String pattern, final Locale locale); static String formatDate(final int style, final Date value); static String formatDate(final int style, final Date value, final Locale locale); static String formatDateTime(final Date value); static String formatDateTime(final Date value, final Locale locale); static String formatDateTime(final int dateStyle, final int timeStyle, final Date value); static String formatDateTime(final int dateStyle, final int timeStyle, final Date value, final Locale locale); static String formatDecimal(final Number value); static String formatDecimal(final Number value, final Locale locale); static String formatPercent(final Number value); static String formatPercent(final Number value, final Locale locale); static String formatPluralCurrency(final Number value); static String formatPluralCurrency(final Number value, final Locale locale); static MessageFormat messageFormatInstance(final String pattern); static MessageFormat messageFormatInstance(final String pattern, final Locale locale); static String naturalDay(final Date value); static String naturalDay(final Date value, final Locale locale); static String naturalDay(final int style, final Date value); static String naturalTime(final Date duration); static String naturalTime(final Date reference, final Date duration); static String naturalTime(final Date reference, final Date duration, final Locale locale); static String naturalTime(final Date duration, final Locale locale); static String ordinalize(final Number value); static String ordinalize(final Number value, final Locale locale); static Number parseNumber(final String text); static Number parseNumber(final String text, final Locale locale); static String pluralize(final Locale locale, final String pattern, final Number value,
            final Object... args); static String pluralize(final String pattern, final Number value, final Object... args); static String replaceSupplementary(final String value); static String smartDateFormat(final Date value, final String skeleton); static String smartDateFormat(final Date value, final String skeleton, final Locale locale); static String spellNumber(final Number value); static String spellNumber(final Number value, final Locale locale); static String transliterate(final String text); static String transliterate(final String text, final String id); }
ICUHumanize { public static String naturalTime(final Date duration) { return context.get().getDurationFormat().formatDurationFromNowTo(duration); } private  ICUHumanize(); static String compactDecimal(final Number value); static String compactDecimal(final Number value, final CompactStyle style); static String compactDecimal(final Number value, final CompactStyle style, final Locale locale); static String compactDecimal(final Number value, final Locale locale); static DateFormat dateFormatInstance(final String pattern); static DateFormat dateFormatInstance(final String pattern, final Locale locale); static DecimalFormat decimalFormatInstance(final String pattern); static DecimalFormat decimalFormatInstance(final String pattern, final Locale locale); static String duration(final Number value); static String format(final String pattern, final Object... args); static String formatCurrency(final Number value); static String formatCurrency(final Number value, final Locale locale); static String formatDate(final Date value); static String formatDate(final Date value, final Locale locale); static String formatDate(final Date value, final String pattern); static String formatDate(final Date value, final String pattern, final Locale locale); static String formatDate(final int style, final Date value); static String formatDate(final int style, final Date value, final Locale locale); static String formatDateTime(final Date value); static String formatDateTime(final Date value, final Locale locale); static String formatDateTime(final int dateStyle, final int timeStyle, final Date value); static String formatDateTime(final int dateStyle, final int timeStyle, final Date value, final Locale locale); static String formatDecimal(final Number value); static String formatDecimal(final Number value, final Locale locale); static String formatPercent(final Number value); static String formatPercent(final Number value, final Locale locale); static String formatPluralCurrency(final Number value); static String formatPluralCurrency(final Number value, final Locale locale); static MessageFormat messageFormatInstance(final String pattern); static MessageFormat messageFormatInstance(final String pattern, final Locale locale); static String naturalDay(final Date value); static String naturalDay(final Date value, final Locale locale); static String naturalDay(final int style, final Date value); static String naturalTime(final Date duration); static String naturalTime(final Date reference, final Date duration); static String naturalTime(final Date reference, final Date duration, final Locale locale); static String naturalTime(final Date duration, final Locale locale); static String ordinalize(final Number value); static String ordinalize(final Number value, final Locale locale); static Number parseNumber(final String text); static Number parseNumber(final String text, final Locale locale); static String pluralize(final Locale locale, final String pattern, final Number value,
            final Object... args); static String pluralize(final String pattern, final Number value, final Object... args); static String replaceSupplementary(final String value); static String smartDateFormat(final Date value, final String skeleton); static String smartDateFormat(final Date value, final String skeleton, final Locale locale); static String spellNumber(final Number value); static String spellNumber(final Number value, final Locale locale); static String transliterate(final String text); static String transliterate(final String text, final String id);  }