{"record":{"id":"13602ea08a398f95","repo":"apache/seatunnel","slug":"unsupported-convert-value-getclass-to-localda-13602e","errorCode":null,"errorMessage":"Unsupported convert ${value.getClass()} to LocalDateTime","messagePattern":"Unsupported convert (.+?) to LocalDateTime","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"seatunnel-api/src/main/java/org/apache/seatunnel/api/table/converter/BasicDataConverter.java","lineNumber":529,"sourceCode":"        if (value instanceof Date) {\n            return convertLocalDateTime((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((String) value);\n        }\n        if (value instanceof Number) {\n            return convertLocalDateTime((Number) value);\n        }\n        throw new UnsupportedOperationException(\n                \"Unsupported convert \" + value.getClass() + \" to LocalDateTime\");\n    }\n\n    default OffsetDateTime convertOffsetDateTime(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) {\n            return ((java.sql.Date) value)\n                    .toLocalDate()\n                    .atTime(LocalTime.MIDNIGHT)","sourceCodeStart":511,"sourceCodeEnd":547,"githubUrl":"https://github.com/apache/seatunnel/blob/cf67b549a7a6c35fa0beb12d83c62892427ea919/seatunnel-api/src/main/java/org/apache/seatunnel/api/table/converter/BasicDataConverter.java#L511-L547","documentation":"This parameterless convertLocalDateTime overload accepts LocalDateTime, String, and Number inputs and throws UnsupportedOperationException for any other class, without a typeDefine in the message. It is the legacy/typed-less variant of error 87 and indicates the temporal conversion path received an unsupported object.","triggerScenarios":"Calling convertLocalDateTime(Object value) directly with Instant, java.util.Date, java.sql.Timestamp, OffsetDateTime, Calendar, or a non-numeric String.","commonSituations":"Mixing the two convertLocalDateTime overloads — assuming the parameterless one is as permissive; framework date wrappers from ORMs or drivers; epoch values boxed as BigDecimal instead of a handled Number subtype (BigDecimal is a Number, but exotic wrappers may not be).","solutions":["Switch to the typeDefine-aware overload convertLocalDateTime(typeDefine, value) which handles more input types (LocalDate, Date, etc.).","Convert explicitly: for Instant use LocalDateTime.ofInstant(instant, zoneId); for java.sql.Timestamp use ts.toLocalDateTime().","Override convertLocalDateTime in a converter subclass to accept the offending type.","If the source is a String, ensure it is parseable as a date-time before calling, or pre-parse with LocalDateTime.parse."],"exampleFix":"// before\nconverter.convertLocalDateTime(instant);\n// after\nconverter.convertLocalDateTime(LocalDateTime.ofInstant(instant, ZoneId.systemDefault()));","handlingStrategy":"type-guard","validationCode":"if (!(value instanceof LocalDateTime) && !(value instanceof String) && !(value instanceof Number)) {\n    throw new IllegalArgumentException(\"convertLocalDateTime(Object) accepts only LocalDateTime/String/Number, got \" + value.getClass());\n}","typeGuard":"boolean isSimpleLocalDateTimeInput(Object v) {\n    return v instanceof LocalDateTime || v instanceof String || v instanceof Number;\n}","tryCatchPattern":"try {\n    return converter.convertLocalDateTime(value);\n} catch (UnsupportedOperationException e) {\n    LOG.warn(\"LocalDateTime conversion failed: {}\", e.getMessage());\n    return null;\n}","preventionTips":["Use the typeDefine-aware overload for Instant/Date inputs.","Convert Instant with LocalDateTime.ofInstant(instant, zoneId) beforehand.","Do not assume both overloads share the same accepted types — check the source.","Keep epoch values as primitive/boxed numeric types (Long), not exotic wrappers."],"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"}