How to convert seconds to hour, minute and seconds in Java

1 Answer

0 votes
public class MyClass {
    public static void main(String args[]) {
		int seconds = 10003;
		
        int s = seconds % 60;
        int h = seconds / 60;
        int m = h % 60;
        
        h = h / 60;
        
        System.out.print(h + ":" + m + ":" + s);
    }
}



/*
run:
 
2:46:43
 
*/

 



answered Aug 8, 2021 by avibootz
...