yzeng1618 commented on code in PR #10048:
URL: https://github.com/apache/seatunnel/pull/10048#discussion_r2570230462
##########
seatunnel-connectors-v2/connector-jdbc/src/main/java/org/apache/seatunnel/connectors/seatunnel/jdbc/utils/JdbcFieldTypeUtils.java:
##########
@@ -95,12 +100,126 @@ public static byte[] getBytes(ResultSet resultSet, int
columnIndex) throws SQLEx
return resultSet.getBytes(columnIndex);
}
+ public static OffsetDateTime getOffsetDateTime(ResultSet resultSet, int
columnIndex)
+ throws SQLException {
+ final Object obj = resultSet.getObject(columnIndex);
+ if (obj == null) {
+ return null;
+ }
+
+ // Handle OffsetDateTime directly
+ if (obj instanceof OffsetDateTime) {
+ return (OffsetDateTime) obj;
+ }
+
+ // Handle ZonedDateTime
+ if (obj instanceof ZonedDateTime) {
+ return ((ZonedDateTime) obj).toOffsetDateTime();
+ }
+
+ // Handle Instant
+ if (obj instanceof Instant) {
+ return ((Instant) obj).atOffset(ZoneOffset.UTC);
+ }
+
+ // Handle java.sql.Timestamp
+ if (obj instanceof Timestamp) {
+ return ((Timestamp)
obj).toLocalDateTime().atOffset(ZoneOffset.UTC);
Review Comment:
Thanks for pointing this out ! Timestamp.toLocalDateTime() depends on the
JVM default time zone, and then .atOffset(UTC) reinterprets that local time as
UTC, which can change the actual instant.
Since Timestamp represents an instant, using ((Timestamp)
obj).toInstant().atOffset(ZoneOffset.UTC) is more accurate, so I’ve updated the
code.
--
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]