Pages

How to convert epoch datetime to human readable datetime - Android

In android default date format is epoch.

What is epoch time?
The Unix epoch (or Unix time or POSIX time or Unix timestamp) is the number of seconds that have elapsed since January 1, 1970 (midnight UTC/GMT), not counting leap seconds (in ISO 8601: 1970-01-01T00:00:00Z).

Human readable time Seconds
1 minute60 seconds
1 hour3600 seconds
1 day86400 seconds
1 week604800 seconds
1 month (30.44 days) 2629743 seconds
1 year (365.24 days)  31556926 seconds

Syntax for convert epoch to normal date in android as follows
long date=System.currentTimeMillis(); //current android time in epoch 
//Converts epoch to "dd/MM/yyyy HH:mm:ss" dateformat
String NormalDate = new java.text.SimpleDateFormat("dd/MM/yyyy HH:mm:ss").format(new java.util.Date(date));   
    
Here is the Resource and link for online epoch converter.

No comments:

Post a Comment