Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Strange behavior with Timezone

Tags:

java

timezone

I run the following Java code :

TimeZone tz1 = TimeZone.getTimeZone("Etc/GMT-3");
System.out.println(tz1.getDisplayName());

The display is GMT+03:00 !

It seems that when we use timezones with ids such as Etc/GMTxx, the sign is reversed. Why ?

like image 531
Arnaud Avatar asked Apr 25 '13 11:04

Arnaud


1 Answers

That is ETC style :

http://en.wikipedia.org/wiki/Zoneinfo

The special area of "Etc" is used for some administrative zones, particularly for "Etc/UTC" which represents Coordinated Universal Time. In order to conform with the POSIX style, those zone names beginning with "Etc/GMT" have their sign reversed from what most people expect. In this style, zones west of GMT have a positive sign and those east have a negative sign in their name (e.g "Etc/GMT-14" is 14 hours ahead/east of GMT.)

like image 200
Suresh Atta Avatar answered Oct 03 '22 22:10

Suresh Atta