jhmannok commented on PR #36519: URL: https://github.com/apache/arrow/pull/36519#issuecomment-1642565356
@lidavidm Yeah so I was also confused at first but according to this article: https://medium.com/@williampuk/sql-timestamp-and-jdbc-timestamp-deep-dive-7ae0ea91e237 it seems like the JDBC drivers for some of the major RDBMS, the provided calendar instance is used to assert that the date and time of the timestamp stored on the db is at the timezone specified by the calendar (ie. if the timestamp is 2022-07-13 00:15 and we pass in a calendar at UTC+8, then we are asserting that the timestamp is 2022-07-13 00:15 UTC+8) then when it is returned, we convert that timestamp into either local system time or UTC+0 (ie. we should see 2022-07-12 16:15 UTC+0 in the timestamp object returned by the method) Quote from article findings: `Providing a Calendar instance We now look at the values returned from ResultSet::getTimestamp(int, Calendar), i.e. the values denoted by (using NY Cal) . The java.util.Calendar object provided to the call is an instance of Calendar at ‘America/New_York’ time zone. According to the Java docs, the method “uses the given calendar to construct an appropriate millisecond value for the timestamp if the underlying database does not store timezone information.” (https://docs.oracle.com/en/java/javase/11/docs/api/java.sql/java/sql/ResultSet.html#getTimestamp(int,java.util.Calendar)) In other words, by providing a Calendar instance, we are telling the driver that, we know the Date and Time value given by the query result is at the time zone of the provided Calendar instance, so please construct a java.sql.Timestamp storing the instant of time computed by all these pieces of information given. It also suggests it does not make sense to use this method if the target type already contains the time zone information, e.g. TIMESTAMP WITH TIME ZONE .` -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
