fork download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6.  
  7. /* Name of the class has to be "Main" only if the class is public. */
  8. class Ideone
  9. {
  10. public static void main (String[] args) throws java.lang.Exception
  11. {
  12. System.out.println(calculateHoursFromMilliSeconds(412));
  13. System.out.println(calculateHoursFromMilliSeconds(60412));
  14. }
  15.  
  16. public static String calculateHoursFromMilliSeconds(long totalMilliSeconds) {
  17. long totalSeconds = totalMilliSeconds / 1000;
  18. long milli = totalMilliSeconds % 1000;
  19. long hours = totalSeconds / 3600;
  20. long minutes = (totalSeconds % 3600) / 60;
  21. long seconds = totalSeconds % 60;
  22. return String.format("%02d:%02d:%02d.%03d", hours, minutes, seconds, milli);
  23. }
  24. }
Success #stdin #stdout 0.1s 320576KB
stdin
Standard input is empty
stdout
00:00:00.412
00:01:00.412