Java Program to Print the Current Date-Time Using Calendar Class

You are currently viewing Java Program to Print the Current Date-Time Using Calendar Class

Java program to print the current date-time using Calendar class

// Java program to print current date-time 
// using Calendar class

import java.util.*;

public class Main {
  public static void main(String[] args) {
    Calendar cal = Calendar.getInstance();

    System.out.println("The Current DateTime is: [" + cal.getTime() + "]");
  }
}

Output

The Current DateTime is: [Fri Apr 01 06:58:17 GMT 2022]

Ranjith

Hi, I'm Manoj a full-time Blogger, YouTuber, Affiliate Marketer, & founder of Coding Diksha. Here, I post about programming to help developers.

Leave a Reply