Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

TIMESTAMPTZ

 
Ginnakunta Laxmi Narayan
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm trying to figure out how to get the time zone information from an
oracle.sql.TIMESTAMPTZ object. According to Oracle's Javadocs, the
getBytes() method returns an array of 13 bytes, the last two of which
specify the time zone -- but all it has to say about *how* the time
zone is represented in those two bytes is "The timezone information is
stored as an offset in the RegionID format or in the HOUR/MINUTE
format". No mention what RegionID format is.

Looking at the TIMESTAMPTZ object returned by the query "select
current_timestamp from dual", casting the ResultSet to OracleResultSet,
and calling getTIMESTAMPTZ(), I got the value 5436 (or 153C hex, with
15 being at index 11 and 3C at index 12 in the byte array). This value
does not look like it's hours/minutes, so I assume it's a RegionID.
BTW, I am in the Central European Time Zone (Netherlands/Amsterdam),
which is UTC+0100.

I don't know how to convert this RegionID value to a time zone ID as
recognized by the Java TimeZone class. And, the only way I have come up
with so far for getting any timezone information at all from
TIMESTAMPTZ is to call timestampValue(), and then use the
getTimezoneOffset() method on the java.sql.Timestamp object. There are
two things wrong with that approach: getTimezoneOffset() is a
deprecated method, and: the value it returns is just an offset in
minutes, not a timezone ID, so I wouldn't be able to distinguish
between CET and any number of African time zones, for instance.

Thanks for any insights or pointers!

- Narayan
 
stu derby
Ranch Hand
Posts: 333
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Ginnakunta Laxmi Narayan:
I'm trying to figure out how to get the time zone information from an
oracle.sql.TIMESTAMPTZ object.


http://www.oracle.com/technology/sample_code/tech/java/sqlj_jdbc/files/9i_jdbc/NewLOBAPISample/NewLOBAPISample.java.html
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic