0 Replies Latest reply on Jan 23, 2015 9:52 AM by 908090

    TIMESTAMP WITH TIME ZONE getting shifted one hour during conversion

    908090

      I am using Oracle 10.2.0.4 and the 10.2.0.4 version of JDBC.

      I have a specific value stored in a TIMESTAMP WITH TIMEZONE column. The value in the DB is 25-DEC-11 08.18.00.000000000 PM -06:00.

      From the ResultSet that returns this value, I perform the following:

      TIMESTAMPTZ tsTZ = (TIMESTAMPTZ)resultSet.getObject(columnNumber);

      TimeZone zone = extractTimeZone(tsTZ.toBytes()); // This returns the correct GMT-06:00 time zone

      Timestamp stamp = tsTZ.timestampValue(connection);

      Calendar cal = Calendar.getInstance(zone);
      cal.setTimeInMillis(stamp.getTime());

      SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd hh:mma Z");
      sdf.setTimeZone(zone);
      System.out.println(sdf.format(cal.getTime()));

      The result is "2011-12-25 07:18 PM -0600"

      For some unknown reason, the time is being shifted by one hour.

      Can anyone shed a light on this?

      Edited by: 905087 on Dec 29, 2011 11:47 AM