Tuesday, March 10, 2015

Conversion of UTC time to Local Time

In order to indicate that a time is measured in Universal Time (UTC), you can append a capital letter Z to a time as in 


The Z stands for the “zero meridian”, which goes through Greenwich in London, and it is also commonly used in radio communication where it is pronounced “Zulu” (the word for Z in the international radio alphabet). Universal Time (sometimes also called “Zulu Time”) was called Greenwich Mean Time (GMT) before 1972, however this term should no longer be used. Since the introduction of an international atomic time scale, almost all existing civil time zones are now related to UTC, which is slightly different from the old and now unused GMT.]

So if it is required to convert UTC Time to Local time

        Calendar parseDateTime = javax.xml.bind.DatatypeConverter.parseDateTime("2015-03-10T07:11:30.079Z");
        Date time = parseDateTime.getTime();

that prints:

Tue Mar 10 09:11:30 EET 2015

while hour is 7 AM at Greenwich Universal Time, it is 9 AM at local.

No comments: