Write a Java program to convert seconds to hour, minute and seconds

Program

import java.util.*;

public class Demo {
    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        System.out.print("Enter Input seconds: ");
        int seconds = s.nextInt();
        int S = seconds % 60;  
        int H = seconds / 60;  
        int M = H % 60;         
        H = H / 60;            
        System.out.println(H + ":" + M + ":" + S);
    }
}
 

Output:

Enter Input seconds: 1224
0:20:24

For latest job updates join Telegram Channel: https://t.me/sateeshm

Programs