code: public static String formatElapsedTime(long millis) {
          // Round to the nearest second.
          long secs = (millis + 500) / 1000;
          StringBuilder buffer = new StringBuilder();
          if (secs > 3600) {
              // >= 1 hour.
              long hours = secs / 3600;
              if (hours == 1) {
                  buffer.append("1 hour");
              } else {
                  buffer.append("" + hours + " hours");
              }
              secs -= hours * 3600;
          }
          if (secs > 60) {
              // Non-zero minutes.
              if (buffer.length() > 0) {
                  buffer.append(", ");
              }
              long mins = secs / 60;
              if (mins == 1) {
                  buffer.append("1 minute");
              } else {
                  buffer.append("" + mins + " minutes");
              }
              secs -= mins * 60;
          }
          if (secs > 0 || buffer.length() == 0) {
              // Non-zero seconds or the enter value is zero.
              if (buffer.length() > 0) {
                  buffer.append(", ");
              }
              if (secs == 1) {
                  buffer.append("1 second");
              } else {
                  buffer.append("" + secs + " seconds");
              }
          }
          return buffer.toString();
      }
docs: Format the given elapsed time in milliseconds as a nice readable string. For
  example:
  3721000 returns "1 hour, 2 minutes, 1 second"
  1500    returns "2 seconds"
  7201000 returns "2 hours, 1 second"
  Milliseconds are rounded to the nearest second.
  
  @param   millis  Elapsed time in milliseconds.
  @return          A string in the format "[[h hour[s][, ]][m minute[s][, ]][s second[s]]"