Mostly, I used to found java programmers having difficulties with getting date and time. Other programming languages have straight forward way to access date and time from the computer. But in java it is bit difficult;
We have to use Calender class, along with the formatter to get own format.
The DateTime class has very useful methods to work with date and time strings.
Note: It only uses upto second part of the timestamp.
Simple use
String now = DateTime.getDate().ToDateTime()
Useful methods
- ToString( [String format])
- ToDateTime()
- ToDate()
- ToTime()
To get the object for further use do following
DateTime now = new DateTime.getDate()
For more details have a look on the code yourself 😀 below
Get it: Date Time Class for Java