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: Wed, 29 Apr 2009 10:15:10 -0400

The "user.timezone" is a JVM System property, try this:
System.out.println(System.getProperties());

You will see an entry similar to this: user.timezone=America/New_York

Now if you run the same test program with the JVM option:
-Duser.timezone=Pacific/Midway, the output will contain:

user.timezone=Pacific/Midway

You can see the list of timezones your jdk supports with
TimeZone.getAvailableIDs()

rdblaha1 wrote:
> Marina Vatkina wrote:
>
>> I'm wondering how can it work with JDBC and fail with JPA... JPA uses the
>> same
>> JDBC API to get the data from the database...
>>
>> Will using property-based persistence where you modify the Date values
>> when they
>> come from the database solve your problem?
>>
>>
>
> I must apologize for listening to partly misleading information from my
> fellow worker. As I am in my beginning days of working with time and dates,
> persistence, and Glassfish I was already working with long values when I
> interfaced with persistence and the database. Using long values I was not
> getting the wrong data as I described it. Because I was seeing what
> appeared to be discrepancies I was prone to believe the problems described
> were the cause. I do apologize for that confusion. What has been said has
> been very useful in learning more about using and establishing a baseline
> that all dates may be established from and compared to.
>
> Once I described to my fellow worker what I was doing and he looked at my
> code he realized that how what he told me was misleading, and what the
> actual problem he faced was; and what I thought was my problem.
>
> What he had told me was when a Date object is passed as a temporal object
> into persistence, persistence in turn converts the Date object to a long.
> It is within this context, either Glassfish or toplink, apparently converts
> the Date object to a long applying the system Timezone on which it resides.
> Since I was already passing in a long I was not truly having the problem
> described. The post from 'matterbury' suggested a user.timezone property
> with Glassfish. I have searched for this without success. If someone
> knows where this property may be accessed, please let me know.
>
> The problem with the Date object conversion to a long by Glassfish or
> toplink still exists. If you have experience in this area, please help.
>
> Thank you.
>