unix timestamp to datetime in android [duplicate]

Solution 1:

You can use new java.util.Date(Long.parseLong(timeInMillis)). With this Date object there are several ways to extract the date in your desired String format, the simplest way using Date.toString(). Alternatively, and more appropriately you can use a SimpleDateFormat with the exact pattern you want.

Solution 2:

This should get you the same time format:

System.currentTimeMillis();