Formats { public static final String toMemorySize(long n) { if (n < (10l << 10)) { return String.valueOf(n); } else if (n < (10l << 20)) { return String.valueOf(n >> 10) + "k"; } else if (n < (10l << 30)) { return String.valueOf(n >> 20) + "m"; } else { return String.valueOf(n >> 30) + "g"; } }  static final String toTimestamp(long millis); static final String toDatestamp(long millis); static final String toFileDatestamp(long millis); static final String currentDatestamp(); static final String currentFileDatestamp(); static final String formatRate(double rate); static final String toMemorySize(long n); static void main(String[] args); static final String ZERO_LEAD_DECIMAL_6; static final String DATE_STAMP; static final String FILE_DATE_STAMP; static final String TIME_STAMP; }
@Test public void testToMemorySize() { assertEquals("3", toMemorySize(3L)); assertEquals("38k", toMemorySize(39327L)); assertEquals("31m", toMemorySize(33553116L)); assertEquals("35g", toMemorySize(38506017581L)); }