コード例 #1
0
    /**
     * @param flags Flags.
     * @return String builder containing all flags.
     */
    static String toString(short flags) {
      SB sb = new SB();

      for (Mask m : MASKS) {
        if (m.ordinal() != 0) sb.a('|');

        sb.a(m.name().toLowerCase()).a('=').a(m.bit(flags));
      }

      return sb.toString();
    }
コード例 #2
0
  /**
   * Pretty-formatting for duration.
   *
   * @param ms Millisecond to format.
   * @return Formatted presentation.
   */
  private static String formatDuration(long ms) {
    assert ms >= 0;

    if (ms == 0) return "< 1 ms";

    SB sb = new SB();

    long dd = ms / 1440000; // 1440 mins = 60 mins * 24 hours

    if (dd > 0) sb.a(dd).a(dd == 1 ? " day " : " days ");

    ms %= 1440000;

    long hh = ms / 60000;

    if (hh > 0) sb.a(hh).a(hh == 1 ? " hour " : " hours ");

    long min = ms / 60000;

    if (min > 0) sb.a(min).a(min == 1 ? " min " : " mins ");

    ms %= 60000;

    if (ms > 0) sb.a(ms).a(" ms ");

    return sb.toString().trim();
  }