In Apache OAK, we use SQL's CURRENT_TIMESTAMP to ask the database for it's idea of the current time (not in order to store it, but to verify that all Oak instances talking to the database have roughly the same system time).
The value is received using a JDBC ResultSet and getTimestamp().getTime()
, which is supposed to return a value suitable for comparison with System.currentTimeMillis()
.
This appeared to work, until somebody tried to connect to a IBM DB2 instance running in a different timezone, in which case the returned timestamp was off by either the TZ difference (or potentially a DST offset constant) - details at https://issues.apache.org/jira/browse/OAK-3645.
So the questions are:
- Is this a known issue with DB2 or its JDBC driver?
- Will this happen for other databases as well?
- Is there an alternative that will work both reliably and portably?