TimeFormat { static void formatUnixDate(int timeDays, StringBuilder appendTo) { long days = timeDays + 719468; long y = (10000*days + 14780) / 3652425; long ddd = days - (365*y + y/4 - y/100 + y/400); if (ddd < 0) { --y; ddd = days - (365*y + y/4 - y/100 + y/400); } long mi = (100*ddd + 52) / 3060; long mm = (mi + 2) % 12 + 1; y = y + (mi + 2) / 12; long dd = ddd - (mi*306 + 5) / 10 + 1; formatInt((int) y, 4, appendTo); appendTo.append('-'); formatInt((int) mm, 2, appendTo); appendTo.append('-'); formatInt((int) dd, 2, appendTo); }  abstract StringBuilder format(long value, StringBuilder str); String format(long value); long parse(CharSequence str); abstract long parse(CharSequence str, ParsePosition pos); static TimeFormat getTimeFormat(TimeUnit unit, Epoch epoch);  }
@Test public void testFormatUnixDate() { StringBuilder s = new StringBuilder(); TimeFormat.formatUnixDate(0, s); assertEquals("1970-01-01", s.toString()); }