Forums Register Login

Timestamps using timezones

+Pie Number of slices to send: Send
I have a timestamp format liek the following passed to me to add to a database: 20080203171600Z-0400

I had a hard time trying to put this in Oracle, but I finally figured it out:

INSERT INTO test_timestamp VALUES
(TO_TIMESTAMP_TZ(REPLACE ('20050203171600Z-0400','Z',' '),'yyyymmddhh24miss TZHTZM'));

test_timestamp has a column with type: TIMESTAMP(0) WITH TIME ZONE


When I retrive this from a resultset, I use the getTimestamp("TEST_TMSTP");


When I use the same date using SimpleDateFormat and call getTime on both, I get different values... Why is that?

SimpleDateFormat fmtTimestamp = new SimpleDateFormat ("yyyyMMddHHmmssZ");
fmtTimestamp.parse(timestamp.replaceAll("Z", ""));

getTimestamp("TEST_TMSTP") = 1107472560000
fmtTimestamp.parse(timestamp.replaceAll("Z", "")) = 1107465360000

Why are these numbers not the same?
+Pie Number of slices to send: Send
Oh disregard the one that says 2008...

I used this one on both attempts:
20050203171600Z-0400
+Pie Number of slices to send: Send
Anyone?
+Pie Number of slices to send: Send
Anthony,
I'm only guessing, but it's probably due to the way "SimpleDateFormat" works. Perhaps this article will help:

http://www.javaworld.com/javaworld/jw-10-2003/jw-1003-time.html

Good Luck,
Avi.
You ought to ventilate your mind and let the cobwebs out of it. Use this cup to catch the tiny ads:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 610 times.
Similar Threads
time conversion
Weather Underground API
why get different result in different java version
Dealing with dates and Zulu time...
Working with dates, timezones, zulu
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 29, 2024 04:21:27.