{"record":{"id":"fa52a74d0b3efc8b","repo":"apache/seatunnel","slug":"unsupported-convert-value-getclass-to-localda-fa52a7","errorCode":null,"errorMessage":"Unsupported convert ${value.getClass()} to LocalDate","messagePattern":"Unsupported convert (.+?) to LocalDate","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"seatunnel-api/src/main/java/org/apache/seatunnel/api/table/converter/BasicDataConverter.java","lineNumber":788,"sourceCode":"        if (value instanceof LocalDate) {\n            return (LocalDate) value;\n        }\n        if (value instanceof Date) {\n            return convertLocalDate((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((String) value);\n        }\n        if (value instanceof Number) {\n            return convertLocalDate((Number) value);\n        }\n        throw new UnsupportedOperationException(\n                \"Unsupported convert \" + value.getClass() + \" to LocalDate\");\n    }\n\n    default LocalDate convertLocalDate(Date value) {\n        return value.toInstant().atZone(ZoneId.systemDefault()).toLocalDate();\n    }\n\n    default LocalDate convertLocalDate(String value) {\n        return LocalDate.parse(value);\n    }\n\n    default LocalDate convertLocalDate(Number value) {\n        if (value.longValue() < 999999999) {\n            return LocalDateTime.ofEpochSecond(\n                            value.longValue(),\n                            0,\n                            ZoneId.systemDefault().getRules().getOffset(LocalDateTime.now()))\n                    .toLocalDate();","sourceCodeStart":770,"sourceCodeEnd":806,"githubUrl":"https://github.com/apache/seatunnel/blob/cf67b549a7a6c35fa0beb12d83c62892427ea919/seatunnel-api/src/main/java/org/apache/seatunnel/api/table/converter/BasicDataConverter.java#L770-L806","documentation":"The typeDefine-less convertLocalDate(Object) handles String, Number and temporal values; an unhandled class causes UnsupportedOperationException naming the value's class. The converter throws because it cannot interpret the value as a LocalDate.","triggerScenarios":"Calling convert()/convertLocalDate(Object) with e.g. java.util.Calendar, char[], or an application object for a DATE column where no instanceof branch matches.","commonSituations":"Custom transforms forwarding untyped Objects; upstream format change (e.g. Avro date logical type now deserialized as a custom class); accidentally passing a timestamp object where the target expects only a date.","solutions":["Pre-convert the value to LocalDate, ISO-8601 String, or epoch Number before calling convert","Inspect the named class and add a custom converter branch if the source always emits it","Fix the source schema/mapping so the field type aligns with the DATE column"],"exampleFix":"// before\nconverter.convert(calendarObj); // throws\n// after\nLocalDate d = ((java.util.Calendar) calendarObj).toInstant().atZone(ZoneId.systemDefault()).toLocalDate();\nconverter.convert(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 isConvertibleToDate(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(value);\n} catch (UnsupportedOperationException e) {\n    LOG.warn(\"Date convert failed, class={}\", value.getClass(), e);\n    value = normalizeToDate(value);\n}","preventionTips":["Convert Calendar/legacy Date types to LocalDate at the boundary","Audit schema drift after format/deserializer changes","Prefer ISO-8601 strings or epoch numbers when interoperating across systems"],"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-14T11:17:12.474Z"}