PluginDateUtils { public static void humanizeDate(long instantMs, long now, boolean showSeconds, StringBuilder buf) { humanizeDate(instantMs, now, TimeZone.getDefault().getID(), showSeconds, buf); } private  PluginDateUtils(); static void humanizeDate(long instantMs, long now, boolean showSeconds, StringBuilder buf); static void humanizeDate(long instantMs, long baseMs, String tzId, boolean showSeconds, StringBuilder buf); static boolean sameDay(long instant1, long instant2, String tzName); static void formatDate(Locale locale, String fmt, long instant, String tzName, StringBuilder buf); static String getTimeZoneNameFromContext(Context ctx);  }
@Test public void testHumanizeDate() { long baseMs = MAY_13_2013_010000_UTC + 30000; assertEquals(humanizeDate(MAY_13_2013_010000_UTC, baseMs, true), "about 30 seconds ago"); assertEquals(humanizeDate(MAY_13_2013_010000_UTC, baseMs, false), "less than a minute ago"); baseMs += ONE_MINUTE_MS; assertEquals(humanizeDate(MAY_13_2013_010000_UTC, baseMs, true), "about a minute ago"); baseMs += ONE_MINUTE_MS; assertEquals(humanizeDate(MAY_13_2013_010000_UTC, baseMs, true), "about 2 minutes ago"); baseMs += (5 * ONE_MINUTE_MS); assertEquals(humanizeDate(MAY_13_2013_010000_UTC, baseMs, true), "about 7 minutes ago"); baseMs += (60 * ONE_MINUTE_MS); assertEquals(humanizeDate(MAY_13_2013_010000_UTC, baseMs, true), "about an hour ago"); baseMs += (60 * ONE_MINUTE_MS); assertEquals(humanizeDate(MAY_13_2013_010000_UTC, baseMs, true), "about 2 hours ago"); baseMs = MAY_13_2013_010000_UTC + (long)(83600000 * 2.5); assertEquals(humanizeDate(MAY_13_2013_010000_UTC, baseMs, true), "about 2 days ago"); baseMs += (ONE_DAY_MS * 5); assertEquals(humanizeDate(MAY_13_2013_010000_UTC, baseMs, true), "about a week ago"); baseMs += (ONE_DAY_MS * 10); assertEquals(humanizeDate(MAY_13_2013_010000_UTC, baseMs, true), "about 2 weeks ago"); assertEquals(humanizeDate(MAY_13_2013_010000_UTC, NOV_15_2013_123030_UTC, true), "about 6 months ago"); assertEquals(humanizeDate(MAY_13_2013_010000_UTC, AUG_24_2015_172345_UTC, true), "about 2 years ago"); }