{"record":{"id":"5f7909438b45baf1","repo":"apache/seatunnel","slug":"unsupported-convert-value-getclass-to-localda-5f7909","errorCode":null,"errorMessage":"Unsupported convert ${value.getClass()} to LocalDate, typeDefine: ${typeDefine}","messagePattern":"Unsupported convert (.+?) to LocalDate, typeDefine: (.+?)","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"seatunnel-api/src/main/java/org/apache/seatunnel/api/table/converter/BasicDataConverter.java","lineNumber":750,"sourceCode":"        if (value instanceof LocalDate) {\n            return (LocalDate) value;\n        }\n        if (value instanceof Date) {\n            return convertLocalDate(typeDefine, (Date) value);\n        }\n        if (value instanceof LocalDateTime) {\n            return ((LocalDateTime) value).toLocalDate();\n        }\n        if (value instanceof java.sql.Date) {\n            return ((java.sql.Date) value).toLocalDate();\n        }\n        if (value instanceof String) {\n            return convertLocalDate(typeDefine, (String) value);\n        }\n        if (value instanceof Number) {\n            return convertLocalDate(typeDefine, (Number) value);\n        }\n        throw new UnsupportedOperationException(\n                \"Unsupported convert \"\n                        + value.getClass()\n                        + \" to LocalDate, typeDefine: \"\n                        + typeDefine);\n    }\n\n    default LocalDate convertLocalDate(T typeDefine, Date value) {\n        return convertLocalDate(value);\n    }\n\n    default LocalDate convertLocalDate(T typeDefine, String value) {\n        return convertLocalDate(value);\n    }\n\n    default LocalDate convertLocalDate(T typeDefine, Number value) {\n        return convertLocalDate(value);\n    }\n","sourceCodeStart":732,"sourceCodeEnd":768,"githubUrl":"https://github.com/apache/seatunnel/blob/cf67b549a7a6c35fa0beb12d83c62892427ea919/seatunnel-api/src/main/java/org/apache/seatunnel/api/table/converter/BasicDataConverter.java#L732-L768","documentation":"convertLocalDate(TypeDefine, Object) supports String, Number (epoch day/millis depending on config) and temporal instances; any other class triggers UnsupportedOperationException with the typeDefine included. It means the field's runtime type has no LocalDate conversion rule in the converter.","triggerScenarios":"Calling convert() for a DATE-mapped column with an unhandled class such as byte[], a BSON date wrapper, or a domain object, when neither the String nor Number branch applies.","commonSituations":"MongoDB/NoSQL drivers returning custom date types; schema drift after connector upgrade changing the deserialized class; passing an epoch value wrapped in a non-Number type like String that isn't ISO-formatted (though String usually routes to parsing).","solutions":["Identify the class from the message and pre-convert to java.time.LocalDate, an ISO-8601 date String, or a Number epoch","Add a custom DataConverter for the offending class if it is consistently produced by the source","Correct the schema mapping so the source field type matches DATE expectations"],"exampleFix":"// before\nconverter.convert(dateTypeDefine, bsonDateTime); // org.bson.BsonDateTime\n// after\nLocalDate d = Instant.ofEpochMilli(((org.bson.BsonDateTime) bsonDateTime).getValue())\n    .atZone(ZoneId.systemDefault()).toLocalDate();\nconverter.convert(dateTypeDefine, d);","handlingStrategy":"type-guard","validationCode":"if (!(v instanceof Number) && !(v instanceof String) && !(v instanceof java.time.temporal.TemporalAccessor) && !(v instanceof java.util.Date)) {\n    throw new IllegalStateException(\"Unsupported date class: \" + v.getClass());\n}","typeGuard":"boolean isDateLike(Object v) {\n    return v instanceof Number || v instanceof String\n        || v instanceof java.time.temporal.TemporalAccessor\n        || v instanceof java.util.Date;\n}","tryCatchPattern":"try {\n    converter.convert(typeDefine, value);\n} catch (UnsupportedOperationException e) {\n    LOG.warn(\"Date conversion failed for {}: {}\", value.getClass(), e.getMessage());\n    value = normalizeToDate(value);\n}","preventionTips":["Normalize NoSQL/driver date wrappers (e.g. BsonDateTime) to java.time before conversion","Keep source schema and target DATE mapping in sync across upgrades","Add conversion tests for all source field classes"],"tags":["java","type-conversion","date","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"}