I'm currently working with different time zones, using java.util.TimeZone
.
First thing I did was to get a list of TimeZone IDs, using TimeZone.getAvailableIDs();
It returned a bunch of Etc/GMT
IDs, such as
Etc/GMT
Etc/GMT+0
Etc/GMT+1
The Javadoc for TimeZone says to use "For example, GMT+10
and GMT+0010
"
To make sure I was using the correct one, I made a small test with both IDs, and the results didn't match what I was expecting:
String id = "GMT-1";
Calendar c = Calendar.getInstance(TimeZone.getTimeZone(id));
System.out.println(id + '\n' + c.getTimeZone().getDisplayName() + " HOUR_OF_DAY " + c.get(Calendar.HOUR_OF_DAY) + '\n');
id = "GMT+1";
c = Calendar.getInstance(TimeZone.getTimeZone(id));
System.out.println(id + '\n' + c.getTimeZone().getDisplayName() + " HOUR_OF_DAY " + c.get(Calendar.HOUR_OF_DAY) + '\n');
id = "Etc/GMT-1";
c = Calendar.getInstance(TimeZone.getTimeZone(id));
System.out.println(id + '\n' + c.getTimeZone().getDisplayName() + " HOUR_OF_DAY " + c.get(Calendar.HOUR_OF_DAY) + '\n');
id = "Etc/GMT+1";
c = Calendar.getInstance(TimeZone.getTimeZone(id));
System.out.println(id + '\n' + c.getTimeZone().getDisplayName() + " HOUR_OF_DAY " + c.get(Calendar.HOUR_OF_DAY) + '\n');
Shows me the output
GMT-1
GMT-01:00 HOUR_OF_DAY 18
GMT+1
GMT+01:00 HOUR_OF_DAY 20
Etc/GMT-1
GMT+01:00 HOUR_OF_DAY 20
Etc/GMT+1
GMT-01:00 HOUR_OF_DAY 18
So my question is: What are these Etc/GMT
IDs for? Why would they give me -X when I used +X and vice versa?