Date and Time in Java
Java provides the Date class available in java.util package, this class contains Date and Time related functions.
For example following program demonstrates how object of Date class can be created.
import java.util.Date;
public class DateDemo {
public static void main(String args[]) {
Date date = new Date(); //Created object of Date Class
// Converted to String and Displayed the same
System.out.println(date.toString());
}
}
Output:
It will show current date and time of the system.