Saturday , October 20 2018
Home / Java / How to get current date time in java

How to get current date time in java

Java provides the Date class available in java.util package, this class encapsulates the current date and time.You can also use Calendar class to get current date and time.

Getting Current Date & Time

This is very easy to get current date and time in Java. You can use a simple Date object with toString() method or Calendar class to print current date and time.
And, later use SimpleDateFormat class to convert the date into a user friendly format.



1. Uisng Date class

2. Using Calendar class

A full example to show you how to use Date() and Calender() classes to get and display the current date time.




About admin

Check Also

Internal Working of HashMap in Java

In this article, we will see how hashmap’s get and put method works internally. What ...

Leave a Reply