Quick actions

cmd+k|ctrl+k

Navigation

Languages

s2hmmss

Snippet info

Language

Java

Visibility

public

Author

mindbound

Created

2017-08-17T01:03:03Z

Updated

2017-08-17T01:03:03Z

// demonstration for https://stackoverflow.com/a/9027362/208437

class Main {
  public static String convertSecondsToHMmSs(long seconds) {
    long s = seconds % 60;
    long m = (seconds / 60) % 60;
    long h = (seconds / (60 * 60)) % 24;
    
    return String.format("%d:%02d:%02d", h, m, s);
  }
  
  public static void main(String[] args) {
    System.out.println(convertSecondsToHMmSs(5000)); // prints "1:23:20"
  }
}
INFO