Lab 2 ___Question 3

PHOTO EMBED

Mon Mar 27 2023 16:06:50 GMT+0000 (Coordinated Universal Time)

Saved by @Mohamedshariif #java

package com.mycompany.currenttime;


public class Currenttime {

    public static void main(String[] args) {
        
    //4.  Write a program that will tell the current time.
    //   Hint use System.currentTimemillis() to get the total number of seconds

        long currentTimemillis = System.currentTimeMillis();
        long totalseconds = currentTimemillis / 1000;
        long secondsnow = totalseconds % 60;
        long totalminutes = totalseconds / 60;
        long minutesnow = totalminutes % 60;
        long totalhours = totalminutes / 60;
        long hoursnow = totalhours % 24;
        
        System.out.println("The current time is: " + hoursnow + ":" +minutesnow + ":" + secondsnow );
        
        
    }
}
content_copyCOPY