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