Java program to print the current date and time
KW.java
import java.util.*;
class KW
{
    public static void main(String args[])
    {
        System.out.println(new Date());
    }
}
KW.java
import java.util.Date;
class KW
{
    public static void main(String args[])
    {
        Date d=new Date();
        System.out.println(d);
    }
}
KW.java
import java.util.Calendar;
class KW
{
    public static void main(String args[])
    {
        Calendar c=Calendar.getInstance();
        System.out.println(c.getTime());
    }
}
Output
kodingwindow@kw:~$ javac KW.java
kodingwindow@kw:~$ java KW Sun Apr 28 11:30:36 IST 2019 kodingwindow@kw:~$
Advertisement