Java Long Number Readable Format humanReadableDuration(long length)

Here you can find the source of humanReadableDuration(long length)

Description

human Readable Duration

License

Apache License

Declaration

static String humanReadableDuration(long length) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

public class Main {
    static String humanReadableDuration(long length) {
        long minutes = length / 60;
        long seconds = length - (minutes * 60);
        StringBuilder builder = new StringBuilder();
        if (minutes != 0) {
            builder.append(minutes).append(" minute");
            if (minutes != 1) {
                builder.append("s");
            }//from  w w  w . ja va 2 s  .  c om
        }
        if (seconds != 0 || minutes == 0) {
            if (builder.length() > 0) {
                builder.append(", ");
            }
            builder.append(seconds).append(" second");
            if (seconds != 1) {
                builder.append("s");
            }
        }
        return builder.toString();
    }
}

Related

  1. humanReadableByteCount(long bytes, boolean si)
  2. humanReadableByteCount(long bytes, boolean si)
  3. humanReadableBytes(long bytes)
  4. humanReadableBytes(long bytes)
  5. humanReadableDateDiff(long start, long end)
  6. humanReadableDuration(long ms)
  7. humanReadableInt(long number)
  8. humanReadableNumber(long total)
  9. humanReadableSize(long byteCount)