Java Duration Format formatDuration(long duration)

Here you can find the source of formatDuration(long duration)

Description

format Duration

License

Apache License

Declaration

public static String formatDuration(long duration) 

Method Source Code

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

public class Main {
    public static String formatDuration(long duration) {
        long hour = (duration / 3600000);
        if (hour == 0)
            return (duration / 60000) + "min " + ((duration % 60000) / 1000) + "s";
        long remaining = duration % 3600000;
        return hour + "h" + (remaining / 60000) + "min" + ((remaining % 60000) / 1000) + "s";
    }/*from w  w w  .java  2 s  .  c om*/
}

Related

  1. formatDuration(int durationMins)
  2. formatDuration(int seconds)
  3. formatDuration(int seconds)
  4. formatDuration(long duration)
  5. formatDuration(long duration)
  6. formatDuration(long duration)
  7. formatDuration(long duration, boolean displayMilliseconds)
  8. formatDuration(long duration, boolean simplify, boolean includeMillies)
  9. formatDuration(long durationInMs)