{"record":{"id":"03d5a86bcef496a7","repo":"apache/seatunnel","slug":"unsupported-convert-value-getclass-to-offsetd","errorCode":null,"errorMessage":"Unsupported convert ${value.getClass()} to OffsetDateTime, typeDefine: ${typeDefine}","messagePattern":"Unsupported convert (.+?) to OffsetDateTime, typeDefine: (.+?)","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"seatunnel-api/src/main/java/org/apache/seatunnel/api/table/converter/BasicDataConverter.java","lineNumber":478,"sourceCode":"            return ((java.sql.Timestamp) value)\n                    .toInstant()\n                    .atZone(ZoneId.systemDefault())\n                    .toOffsetDateTime();\n        }\n        if (value instanceof Date) {\n            return ((Date) value).toInstant().atZone(ZoneId.systemDefault()).toOffsetDateTime();\n        }\n        if (value instanceof LocalDate) {\n            return ((LocalDate) value)\n                    .atTime(LocalTime.MIDNIGHT)\n                    .atZone(ZoneId.systemDefault())\n                    .toOffsetDateTime();\n        }\n        if (value instanceof String) {\n            return OffsetDateTime.parse((String) value);\n        }\n\n        throw new UnsupportedOperationException(\n                \"Unsupported convert \"\n                        + value.getClass()\n                        + \" to OffsetDateTime, typeDefine: \"\n                        + typeDefine);\n    }\n\n    default LocalDateTime convertLocalDateTime(T typeDefine, Instant value) {\n        return convertLocalDateTime(value);\n    }\n\n    default LocalDateTime convertLocalDateTime(T typeDefine, Date value) {\n        return convertLocalDateTime(value);\n    }\n\n    default LocalDateTime convertLocalDateTime(T typeDefine, String value) {\n        return convertLocalDateTime(value);\n    }\n","sourceCodeStart":460,"sourceCodeEnd":496,"githubUrl":"https://github.com/apache/seatunnel/blob/cf67b549a7a6c35fa0beb12d83c62892427ea919/seatunnel-api/src/main/java/org/apache/seatunnel/api/table/converter/BasicDataConverter.java#L460-L496","documentation":"convertOffsetDateTime supports OffsetDateTime, LocalDateTime (converted via zone), String (parsed with OffsetDateTime.parse), and related temporal inputs; any other class throws this UnsupportedOperationException naming the class and typeDefine. It means the value routed to TIMESTAMP_WITH_TIMEZONE conversion cannot be interpreted as an OffsetDateTime.","triggerScenarios":"Calling convertOffsetDateTime(typeDefine, value) — or convert(...) with a TIMESTAMP_WITH_LOCAL_TIME_ZONE/SqlType mapping to OffsetDateTime — with an Instant, java.util.Date, java.sql.Timestamp, ZonedDateTime, Long, or unparseable date object.","commonSituations":"Drivers returning java.sql.Timestamp or Instant while the schema expects OffsetDateTime; legacy epoch-millis Longs; date strings in a non-ISO-8601 format reaching OffsetDateTime.parse and failing earlier, or non-temporal objects hitting this throw.","solutions":["Convert the value explicitly first: instant.atZone(zone).toOffsetDateTime(), ts.toInstant().atOffset(ZoneOffset.UTC), etc.","If the value is a String, ensure it is ISO-8601 with an offset, or parse it with a custom DateTimeFormatter before passing an OffsetDateTime.","Override convertOffsetDateTime in a converter subclass for framework-specific temporal types.","Align the schema: if offsets are irrelevant, use a TIMESTAMP column with LocalDateTime instead."],"exampleFix":"// before\nconverter.convertOffsetDateTime(typeDefine, sqlTimestamp);\n// after\nconverter.convertOffsetDateTime(typeDefine, sqlTimestamp.toInstant().atOffset(ZoneOffset.UTC));","handlingStrategy":"type-guard","validationCode":"if (!(value instanceof OffsetDateTime) && !(value instanceof LocalDateTime) && !(value instanceof String)\n    && !(value instanceof java.time.ZonedDateTime) && !(value instanceof java.time.Instant)) {\n    throw new IllegalArgumentException(\"Unsupported offset datetime input: \" + value.getClass());\n}","typeGuard":"boolean isOffsetDateTimeConvertible(Object v) {\n    return v instanceof OffsetDateTime || v instanceof LocalDateTime || v instanceof String\n        || v instanceof ZonedDateTime || v instanceof Instant;\n}","tryCatchPattern":"try {\n    return converter.convertOffsetDateTime(typeDefine, value);\n} catch (UnsupportedOperationException e) {\n    LOG.warn(\"OffsetDateTime conversion failed for {}: {}\", value.getClass(), e.getMessage());\n    return null;\n}","preventionTips":["Convert Instant/Date/Timestamp via atOffset(ZoneOffset.UTC) or atZone(zone).toOffsetDateTime().","Ensure String inputs are ISO-8601 with an offset before passing them.","Pick TIMESTAMP (LocalDateTime) instead of TIMESTAMP_WITH_TIMEZONE when offsets are irrelevant.","Pin a default ZoneId in application config for consistent conversions."],"tags":["type-mismatch","datetime-conversion","seatunnel-api"],"backgroundTag":"type-mismatch","analyzedSha":"cf67b549a7a6c35fa0beb12d83c62892427ea919","analyzedAt":"2026-09-10T21:44:55.265Z","contentChangedAt":"2026-09-10T21:44:55.265Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}