Java Program to Display the Current Time

bookmark

import java.time.LocalTime;
public class Main
{
    public static void main(String[] args)
    {
        // Create a variable of LocalTime as ‘date’, call an inbuild method of LocalTime “.now()” to get the current time and store the result in the variable “date”
          LocalTime date = LocalTime.now();
        // Print the result
         System.out.println("The current time in 24 hour format is "+ date);
    }
}

 


Output:

The current time in 24 hour format is 07:52:55.654615