Date: Wed, 13 Mar 2002 08:09:18 -0700 From: Stacy Millions <stacy@millions.ca> To: Timothy Kettering <timster@blackcore.com> Cc: FreeBSD-Java <java@FreeBSD.ORG> Subject: Re: Setting the JVM timezone Message-ID: <3C8F6B9E.CA1AADBA@millions.ca> References: <B8B44B38.583D%timster@blackcore.com>
next in thread | previous in thread | raw e-mail | index | archive | help
This is a multi-part message in MIME format. --------------E8337002D7EF6B1939B27BD6 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Timothy Kettering wrote: > > I realized just now that I had not updated to the patchset6, so I > just did that then reran my tests - still seems that the FreeBSD > native jdk is incorrectly seeing the timezone, while the linux-jdk > reports the right timezone. > > $ /usr/local/jdk1.3.1/bin/java TestRun > The TZ is: GMT+06:00 > $ /usr/local/linux-jdk1.3.1/bin/java TestRun > The TZ is: GMT-06:00 That is reproducible by me as well. Note that setting the TZ environment variable works around the problem. TZ="" - date output Wed Mar 13 07:50:22 MST 2002 TZ="" - native 1.3.1-p6 It is: 2002.03.13 at 21:50:23 GMT+07:00 TZ="" - linux 1.3.1 It is: 2002.03.13 at 07:50:24 GMT-07:00 TZ="" - my patched native 1.3.1 It is: 2002.03.13 at 07:50:25 GMT-07:00 TZ="MST7MDT" - date output Wed Mar 13 07:50:25 MST 2002 TZ="MST7MDT" - native 1.3.1-p6 It is: 2002.03.13 at 07:50:26 MST TZ="MST7MDT" - linux 1.3.1 It is: 2002.03.13 at 07:50:27 MST TZ="MST7MDT" - my patched native 1.3.1 It is: 2002.03.13 at 07:50:28 MST I tracked down (what I think is) the problem. In the file .../src/solaris/native/java/util/TimeZone_md.c you will find the following (this is the original unpatched source) /* Note that the time offset direction is opposite. */ if (timezone > 0) { offset = timezone; sign = '-'; } else { offset = -timezone; sign = '+'; } p6 turns it into: /* Note that the time offset direction is opposite. */ #if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__bsdi__) struct tm *local_tm; time_t clock = time(NULL); tzset(); local_tm = localtime(&clock); if (local_tm->tm_gmtoff > 0) { offset = (time_t) local_tm->tm_gmtoff; sign = '-'; } else { offset = (time_t) -local_tm->tm_gmtoff; sign = '+'; } #else if (timezone > 0) { offset = timezone; sign = '-'; } else { offset = -timezone; sign = '+'; } #endif all I did was swap the '+' and '-' and the problem went away. (see attached diff file) Please note that I spent all of .5 hours looking at this (and less testing it), so I don't know if this breaks something else. -stacy -- You'll see it's all a show. Keep 'em laughing as you go. Just remember that the last laugh is on you. - Monty Python _The Life Of Brian_ Stacy Millions stacy@millions.ca Millions Consulting Limited --------------E8337002D7EF6B1939B27BD6 Content-Type: text/plain; charset=us-ascii; name="TimeZone.diff" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="TimeZone.diff" *** TimeZone_md.c-p6 Wed Feb 20 07:54:39 2002 --- TimeZone_md.c Tue Mar 12 21:18:37 2002 *************** *** 390,400 **** local_tm = localtime(&clock); if (local_tm->tm_gmtoff > 0) { offset = (time_t) local_tm->tm_gmtoff; ! sign = '-'; } else { offset = (time_t) -local_tm->tm_gmtoff; ! sign = '+'; } #else if (timezone > 0) { --- 390,400 ---- local_tm = localtime(&clock); if (local_tm->tm_gmtoff > 0) { offset = (time_t) local_tm->tm_gmtoff; ! sign = '+'; } else { offset = (time_t) -local_tm->tm_gmtoff; ! sign = '-'; } #else if (timezone > 0) { --------------E8337002D7EF6B1939B27BD6-- To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-java" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?3C8F6B9E.CA1AADBA>