Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Re: Read GMT dates in Java

Re: Read GMT dates in Java

From: C. Ferguson <c_ferguson_at_rationalconcepts.com>
Date: Fri, 30 Nov 2001 01:23:10 GMT
Message-ID: <3C06DFA6.BC39C28C@rationalconcepts.com>


Try storing it as a long (see java api for Date class getTime() method)

hth,
cindy
gunjeet singh wrote:

> I have a question about storing the dates in GMT in the database and
> reading
> them back through JDBC in a java program.
>
> We have machines in different timezones from which we collect the data
> and store in a centralized server. The timezone in which you view this
> data could still be different from the timezone of the machines from
> where data is collected and the timezone of the server.
>
> Here's what we do :
>
> Assume a machine in EST timezone. If data is collected at 6PM EST and
> brought over to the server in PST TZ, the data is logged as below :
>
> SQL> select to_char(opened,'DD MON YYYY HH:MI:SSAM') from test where id
> = 123;
>
> TO_CHAR(OPENED,'DDMONYYYYHH:
> ---------- -------------------------
>
> 29 NOV 2001 11:00:00PM
>
> Please note that I haven't used any sql functions, simply done a to_char
> on the stored value.
>
> What we see in the database is the EST time stored in GMT format (6PM
> EST = 6 + 5 = 11 PM GMT) and it's the same if we were to interpret it
> as the PST time stored in GMT (3PM PST + 8 = 11 PM GMT).
>
> How should we read it in a Java program ? We currently do a
> getTimestamp(columnIndx) on the resultset. We then create a
> java.util.Date object using the ts.getTime() method. It appears that
> the java date interprets the GMT date/time coming from the database as a
> PST
> date/time and adds another 8 hours to that to return the long value.
>
> We have even tried using a Calender object (with GMT TZ set) while
> invoking the getTimestamp method but it doesn't help.
>
> Can someone help and explain how we should be reading these dates
> that are stored in GMT in the database ?
Received on Thu Nov 29 2001 - 19:23:10 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US