I want to print current date and time in java..This is the code I am trying from a java tutorial:
import java.util.*;
public class Date {
public static
You can try this,
import java.util.Date;
public class CurrentDate
{
public static void main(String[] args)
{
Date currentDate = new Date();
System.out.println("Curent Date and Time - " + currentDate.toString());
}
}
Output:
Mon May 04 09:51:52 CDT 2009
Also, you can refer links below on date and time formatting. Quite useful.
https://docs.oracle.com/javase/tutorial/datetime/iso/datetime.html
https://docs.oracle.com/javase/7/docs/api/java/sql/Date.html
https://www.flowerbrackets.com/date-time-java-program/