Java Second Format formatSeconds(long seconds)

Here you can find the source of formatSeconds(long seconds)

Description

format Seconds

License

Open Source License

Declaration

public static String formatSeconds(long seconds) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

public class Main {
    public static String formatSeconds(long seconds) {
        long d = seconds / 3600 / 24;
        long h = (seconds / 3600) % 24;
        long m = (seconds / 60) % 60;
        long s = seconds % 60;
        if (d > 0)
            return d + "d" + h + "h" + m + "m" + s + "s";
        if (h > 0)
            return h + "h" + m + "m" + s + "s";
        if (m > 0)
            return m + "m" + s + "s";
        return s + "s";
    }//from  w  ww  .  j  a  va 2s.  c o  m
}

Related

  1. formatSeconds(int seconds)
  2. formatSeconds(int seconds)
  3. formatSeconds(long dSeconds, boolean exact)
  4. formatSeconds(long millis)
  5. formatSeconds(long s, boolean letters)
  6. formatSeconds(long seconds)
  7. formatSeconds(long secsIn)
  8. formatSeconds(long time)
  9. formatSeconds(long time)