Reputation: 743
I do have a problem with OJDBC8. Sometime ago I decided to switch from OJDBC6 -> OJDBC8 and some of the functionality that worked before stopped working. I have a Calendar object with GMT-4 and all other properties. When I am using OJDBC6 this code below works fine, the TIMESTAMP is adjusted to the time zone.
rs.getTimestamp(1, calendar)
When using OJDBC8 and the same code as above the timestamp isn't adjusted, basically the timestamp does not change it has the same value as in the database. I've checked the OJDBC8 code and the logic is different between version 6&8. I do not understand why we pass calendar object to getTimestamp() method but it isn't even used in OJDBC8.
Upvotes: 0
Views: 1096
Reputation: 78945
Note that the Java compiler level for ojdbc8
was Java-8 while that for ojdbc6
was Java-6. With Java-8, a completely new date-time API was introduced. The legacy date-time API (java.util
) was error-prone and the code using them used to be complex and difficult to understand.
You should use the modern date-time API (java.time
) and do it as follows:
OffsetDateTime odt = rs.getObject(1, OffsetDateTime.class);
Learn more about the modern date-time API from Trail: Date Time
The changes you will make in order to switch to the modern date-time API will be worth and will help you in the long-term.
Upvotes: 1