Date Class in java:
There is a Date class in java under java.util package which can be used to print the current dates. There can be various ways to print the current date. Lets see with the help of example:
import java.util.Date;
public class DateDemo {
public static void main(String args[]) {
Date date=new Date(); // Simple way of getting date
System.out.println(date);
long milliSeconds=System.currentTimeMillis();
date=new Date(milliSeconds); // passing the milliseconds since January 1970
System.out.println(date);
date=java.util.Calendar.getInstance().getTime(); // printing with the help of Calendar object
System.out.println(date);
}
}
So the output will be:
Wed Mar 30 17:01:33 IST 2016
Wed Mar 30 17:01:33 IST 2016
Wed Mar 30 17:01:33 IST 2016
0 Comment(s)