datetime – How to convert timestamp to readable time without considering time zones and daylight saving time?


There is a method for converting UTC time to a readable format.

public static String convertUTC(final long time)
        final Calendar calendar = new GregorianCalendar(TimeZone.getTimeZone("UTC"));
        final SimpleDateFormat format = new SimpleDateFormat("yyyy:MM:dd HH:mm:ss");
        return format.format(calendar.getTime());

But the problem is that the time is obtained taking into account the transition to summer and winter time, and the time zone on the device is also taken into account

For example, if you call


then it will return 2014: 04: 17 01:28:32 . At this moment, the time zone is GMT + 6 on the device


The problem is solved, it was necessary to add

Scroll to Top