user2874190 user2874190 - 11 months ago 59
Android Question

How to convert the string containing UTC time such as "193526"(19:35:26) to local time zone?

I am writing an app about GPS and I have to convert the string of UTC time obtained from NMEA format to local time.

The strings are formatted as "193526" which represents 19:35:26 UTC(GMT).

How can I convert it to local time such as "15:35:26 EDT"?


EDT TimeZone does not exist in jdk. See the answer here.

You can do the conversion this way:

    SimpleDateFormat formatUTC = new SimpleDateFormat("HHmmss");
    Date date = formatUTC.parse("193526");

    SimpleDateFormat formatEDT = new SimpleDateFormat("HH:mm:ss z");

15:35:26 GMT-04:00