How to get Current Date in Readable format from currentTimeMillis

Here is the simple code to get Current Date from the System in readable format.

In xml design write a code for button or just drag and drop Button from the Design tab.

Set the listener for the button. Inside the Button listener 

First of all get the time value from the System. Using System.currentTimeMillis() method, which will give time in milliseconds. 

Second, use SimpleDateFormat class to get date value in specified pattern, also with the specified locale.

Third, pass the milliseconds value in the Date method and 

Finally, format the date value by passing it into the SimpleDateFormat format()  method.

That’s it. Print the result in Log or display in Toast.

Leave a Comment

Your email address will not be published. Required fields are marked *