GMT offsets: Java vs Unix
Java is interprets GMT[+-]<offset> time zone values differently than Unix utilities such as 'date'. For example, I have a simple test program that grabs the current time with a call to Calendar.getInstance() and then prints out this time using the DateFormat.getDateTimeInstance() formatter. Here is some output:
$ TZ=GMT-1 date
Thu May 10 17:26:39 GMT 2007
$ TZ=GMT+1 date
Thu May 10 15:26:43 GMT 2007
$ TZ=GMT-1 java -cp . TestCalendar
May 10, 2007 3:26:53 PM
$ TZ=GMT+1 java -cp . TestCalendar
May 10, 2007 5:26:58 PM
This was reproduced using a 1.4.2-13 and 1.5.0-07 JRE, both on Solaris 10 (i386), and with a 1.5.0-03 JRE on a Linux machine. And I have found documentation from Sun supporting that this is intended behavior for Java. Switching to UTC provides consistent results between Unix utilities and Java:
$ TZ=UTC-1 date
Thu May 10 17:37:22 UTC 2007
$ TZ=UTC-1 java -cp . TestCalendar
May 10, 2007 5:37:29 PM
What's with this inconsistency? Is there some reason for it? We are in the process of switching the value used for TZ for the environment in question, so no need to suggest that. I just want to understand this seemingly bizarre behavior.
Thanks in advance!
Chris Rorvick

