{"record":{"id":"5c0a29ed4622736e","repo":"apache/seatunnel","slug":"unsupported-convert-value-getclass-to-localda","errorCode":null,"errorMessage":"Unsupported convert ${value.getClass()} to LocalDateTime, typeDefine: ${typeDefine}","messagePattern":"Unsupported convert (.+?) to LocalDateTime, typeDefine: (.+?)","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"seatunnel-api/src/main/java/org/apache/seatunnel/api/table/converter/BasicDataConverter.java","lineNumber":434,"sourceCode":"        if (value instanceof Date) {\n            return convertLocalDateTime(typeDefine, (Date) value);\n        }\n        if (value instanceof LocalDate) {\n            return convertLocalDateTime((LocalDate) value);\n        }\n        if (value instanceof java.sql.Date) {\n            return convertLocalDateTime((java.sql.Date) value);\n        }\n        if (value instanceof java.sql.Timestamp) {\n            return convertLocalDateTime((java.sql.Timestamp) value);\n        }\n        if (value instanceof String) {\n            return convertLocalDateTime(typeDefine, (String) value);\n        }\n        if (value instanceof Number) {\n            return convertLocalDateTime(typeDefine, (Number) value);\n        }\n        throw new UnsupportedOperationException(\n                \"Unsupported convert \"\n                        + value.getClass()\n                        + \" to LocalDateTime, typeDefine: \"\n                        + typeDefine);\n    }\n\n    default OffsetDateTime convertOffsetDateTime(T typeDefine, Object value)\n            throws UnsupportedOperationException {\n        if (value instanceof OffsetDateTime) {\n            return (OffsetDateTime) value;\n        }\n        if (value instanceof LocalDateTime) {\n            return ((LocalDateTime) value).atZone(ZoneId.systemDefault()).toOffsetDateTime();\n        }\n        if (value instanceof Instant) {\n            return ((Instant) value).atZone(ZoneId.systemDefault()).toOffsetDateTime();\n        }\n        if (value instanceof java.sql.Date) {","sourceCodeStart":416,"sourceCodeEnd":452,"githubUrl":"https://github.com/apache/seatunnel/blob/cf67b549a7a6c35fa0beb12d83c62892427ea919/seatunnel-api/src/main/java/org/apache/seatunnel/api/table/converter/BasicDataConverter.java#L416-L452","documentation":"The typeDefine-aware convertLocalDateTime supports LocalDateTime, LocalDate, Date, String (parsed), and Number (epoch millis) inputs; any other class throws this UnsupportedOperationException. typeDefine is included to show the target timestamp type. It means the value on the TIMESTAMP conversion path has an unsupported runtime type.","triggerScenarios":"Calling convertLocalDateTime(typeDefine, value) — or convert(...) with a TIMESTAMP SqlType — with a java.sql.Timestamp, Instant, OffsetDateTime, Calendar, Long-as-String, or other unsupported temporal object.","commonSituations":"JDBC returning java.sql.Timestamp (subclass nuance) or the driver's own datetime wrapper; deserialized epoch values as Strings; microsecond-precision objects (Instant) that the converter does not handle.","solutions":["Convert the value to LocalDateTime first, e.g. LocalDateTime.ofInstant(instant, ZoneOffset.UTC) or timestamp.toLocalDateTime().","If the value is a numeric epoch in a String, parse it to long and pass the Number form so it is treated as epoch millis.","Override convertLocalDateTime in a converter subclass to support the offending temporal type.","Confirm the unit of the epoch value (millis vs micros vs seconds) and normalize before conversion."],"exampleFix":"// before\nconverter.convertLocalDateTime(typeDefine, instant);\n// after\nconverter.convertLocalDateTime(typeDefine, LocalDateTime.ofInstant(instant, ZoneId.systemDefault()));","handlingStrategy":"type-guard","validationCode":"if (!(value instanceof LocalDateTime) && !(value instanceof LocalDate) && !(value instanceof java.util.Date)\n    && !(value instanceof String) && !(value instanceof Number)) {\n    throw new IllegalArgumentException(\"Unsupported temporal type: \" + value.getClass());\n}","typeGuard":"boolean isLocalDateTimeConvertible(Object v) {\n    return v instanceof LocalDateTime || v instanceof LocalDate || v instanceof java.util.Date\n        || v instanceof String || v instanceof Number;\n}","tryCatchPattern":"try {\n    return converter.convertLocalDateTime(typeDefine, value);\n} catch (UnsupportedOperationException e) {\n    LOG.warn(\"Temporal conversion failed for {}: {}\", value.getClass(), e.getMessage());\n    return null;\n}","preventionTips":["Convert Instant/Timestamp to LocalDateTime with an explicit zone before conversion.","Clarify epoch units (millis/micros/seconds) and normalize to millis for the Number path.","Pre-parsing String dates with a fixed formatter avoids parser surprises downstream.","Test with the exact types your JDBC/ORM driver returns."],"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-14T05:17:10.506Z"}