Date: Tue, 12 Mar 2002 18:27:03 -0600 From: Timothy Kettering <timster@blackcore.com> To: FreeBSD-Java <java@FreeBSD.ORG> Subject: Re: Setting the JVM timezone Message-ID: <B8B3F8F7.582D%timster@blackcore.com> In-Reply-To: <20020312191638.A5376@fritz.cc.gt.atl.ga.us>
next in thread | previous in thread | raw e-mail | index | archive | help
>> I brought this up before, but I didn=B9t really get an satisfactory >> answer/explaination, so I'm bringing it up again. >=20 > I missed your previous question/answer, and might repeat old > information. What was lacking? My previous question was the same what I wrote in this email. The response= s were that I should set the timezone in my programs to compenstate for this. I wasn't really satisfied with the answers, because I wanted to know why th= e freebsd JVM was thinking it was in, of all places, +600GMT? That puts it somewhere over India. If it was defaulting to GMT, that would've made a whole lot more sense, if it were indeed defaulting to some value. > So, perhaps check 'date "+%Z"' (for bash), and see if this property is > being consulted. I ran that command on the FreeBSD server, and I got "CST" returned. And this is correct. I am in the CST time zone. So as far as I know, the server clock is set to the right timezone, (CST, -600 GMT). But requesting the timezone in any java application I execute on the server gets me (+600 GMT). And this makes absolutely no sense. Where is this value coming from?? It's not CST, or even GMT. The exact output of a simple program I included with this email (see below) is: The TZ is: GMT+06:00 >=20 > Also, I recall that there was some issue with certain caledar objects > not having the same default TZ. That is, some/most would get GMT, but > a few would have PST for a default. This was years ago, and perhaps > this has been addressed. Still, it might be that your code interacts > with this. I don=B9t use any Calendar objects. My programs are merely using Date objects, then being formatted with SimpleDateFormat. Hence, all my problem= s origniate from the misalignment of the JVM timezone. Because I'll instance a Date, then run a SimpleDateFormat.format(), on it, and on my development machine, it comes out just perfectly fine. On the FreeBSD machine, it come= s out 12 hours in the future. > In terms of fixing this, you might just make a static > setSaneTZ(String) method, and drop this in your scratch/utility > package for future use. One line, and your time components are all on > the same time zone. :) Yes, I could put this in, but I'm also the kind of person who dislikes putting in a fix on top of a problem that (in my perspective) shouldn't be = a problem to start with. Better to resolve the problem itself, I think. So I'm hoping to prod the discussion up again on this - to see if its actually an legimate bug with the FreeBSD JVM or something. For this problem does not exist on the OSX JVM implementation which I develop under. Can people on this list run a simple program on their FreeBSD environment, and see if it returns the same TZ value that their server clock is set to, and let the list know? Thanks. import java.util.Date; import java.text.SimpleDateFormat; public class TestRun { public static void main(String[] args) { SimpleDateFormat formatter =3D new SimpleDateFormat("zzz"); String str =3D formatter.format(new Date()); System.out.println("The TZ is: " + str); } } --=20 Tim Kettering http://www.blackcore.com 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?B8B3F8F7.582D%timster>