Thursday, September 29, 2022

JAVA Code to get Current Date and Time

In JAVA, we can use  GregorianCalendar class to get current Date and Time.


 JAVA Code to get Current Date and Time



Code : 

public class Test {

    

    public static void main(String a[])

    {

        GregorianCalendar gc = new GregorianCalendar();

        System.out.print(gc.getTime());

    

    }

    

}



Output :


Fri Sep 30 10:38:51 IST 2022

No comments:

Post a Comment