users@glassfish.java.net

Re: Timezones, Glassfish, Two different systems: How do I change the TZ of Glassfish?

From: Alex Sherwin <alex.sherwin_at_acadiasoft.com>
Date: Fri, 24 Apr 2009 14:16:04 -0400

The underlying JDK uses the systems time I believe...

However, you can still compare these times appropriately without making
any changes. The java.util.Date object is backed by an epoch timestamp
in millis, which is the same generated in UTC on your production server
and your local timezone on your development machine).

However, since when you create your java.util.Date object on your dev
machine, you're applying a timezone (lets say EST), format its output
with a SimpleDateFormat or something similar, it appears to be different
(but only because the SDF is doing you a favor and displaying it in your
local time).

The times are still the same, just being displayed contextually differently.

You could either compare timestamps with the .getTime() method of
java.util.Date, or instantiate a new java.util.Calendar and force its
time zone like this:

final Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("GMT"));

You can then set the epoch timestamp on the calendar, and get a new date
object with the getTime() method on java.util.Calendar, which will
return you a Date object in GMT

I'm sure theres plenty of other ways you could accomplish this as well

rdblaha1 wrote:
> I am developing on my local system (Windows XP) set to the Time Zone in which
> I work. I am developing for a system that provides Glassfish in UTC (on the
> production server - non-Windows). When I run my Date (and time)
> calculations which also are to provide access from any time zone I cannot
> test my software to provide similar results as what the production
> environment will return.
>
> Is there a way to change the timezone for Glassfish on my local system
> without changing the timezone of the whole system?
>
>
>