{"record":{"id":"c45aa41dacff33e5","repo":"apache/seatunnel","slug":"unsupported-convert-value-getclass-to-localti","errorCode":null,"errorMessage":"Unsupported convert ${value.getClass()} to LocalTime, typeDefine: ${typeDefine}","messagePattern":"Unsupported convert (.+?) to LocalTime, typeDefine: (.+?)","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"seatunnel-api/src/main/java/org/apache/seatunnel/api/table/converter/BasicDataConverter.java","lineNumber":644,"sourceCode":"        if (value instanceof Time) {\n            return convertLocalTime(typeDefine, (Time) value);\n        }\n        if (value instanceof LocalDateTime) {\n            return convertLocalTime((LocalDateTime) value);\n        }\n        if (value instanceof java.sql.Timestamp) {\n            return convertLocalTime((java.sql.Timestamp) value);\n        }\n        if (value instanceof String) {\n            return convertLocalTime(typeDefine, (String) value);\n        }\n        if (value instanceof Number) {\n            return convertLocalTime(typeDefine, (Number) value);\n        }\n        if (value instanceof Duration) {\n            return convertLocalTime((Duration) value);\n        }\n        throw new UnsupportedOperationException(\n                \"Unsupported convert \"\n                        + value.getClass()\n                        + \" to LocalTime, typeDefine: \"\n                        + typeDefine);\n    }\n\n    default LocalTime convertLocalTime(T typeDefine, Time value) {\n        return convertLocalTime(value);\n    }\n\n    default LocalTime convertLocalTime(T typeDefine, String value) {\n        return convertLocalTime(value);\n    }\n\n    default LocalTime convertLocalTime(T typeDefine, Number value) {\n        return convertLocalTime(value);\n    }\n","sourceCodeStart":626,"sourceCodeEnd":662,"githubUrl":"https://github.com/apache/seatunnel/blob/cf67b549a7a6c35fa0beb12d83c62892427ea919/seatunnel-api/src/main/java/org/apache/seatunnel/api/table/converter/BasicDataConverter.java#L626-L662","documentation":"convertTime(TypeDefine, Object) tries Number, String, Duration and a few temporal types before giving up; if the value's class matches none of them it throws UnsupportedOperationException including the target typeDefine for diagnosis. The library throws it because there is no defined rule to interpret the value as a LocalTime.","triggerScenarios":"Calling convert() with a TIME-mapped column when the value is an unhandled class — e.g. java.sql.Timestamp, byte[] from a binary protocol, or a micros-long wrapped in a non-Number type — so no branch in convertTime matches.","commonSituations":"CDC formats delivering time as struct/wrapped types; JDBC drivers returning java.sql.Time subclasses not matched by instanceof checks; schema mismatch where a source string column maps to a TIME sink column but carries non-ISO text.","solutions":["Read value.getClass() and typeDefine in the message to identify the offending class and target type","Convert the value beforehand to one of the supported inputs: ISO LocalTime String, Number (nanos/millis per converter config), Duration, or LocalTime","Add a custom DataConverter implementation for that class if the source always emits it","Fix the schema mapping so the field type matches what the source actually produces"],"exampleFix":"// before\nconverter.convert(timeTypeDefine, javaSqlTimestamp); // throws\n// after\nLocalTime t = ((java.sql.Timestamp) javaSqlTimestamp).toLocalDateTime().toLocalTime();\nconverter.convert(timeTypeDefine, t);","handlingStrategy":"type-guard","validationCode":"// before calling convert\nif (!(v instanceof Number) && !(v instanceof String) && !(v instanceof java.time.Duration) && !(v instanceof java.time.temporal.TemporalAccessor)) {\n    throw new IllegalStateException(\"Unsupported time class: \" + v.getClass());\n}","typeGuard":"boolean isTimeLike(Object v) {\n    return v instanceof Number || v instanceof String\n        || v instanceof java.time.Duration\n        || v instanceof java.time.LocalTime;\n}","tryCatchPattern":"try {\n    LocalTime t = (LocalTime) converter.convert(typeDefine, value);\n} catch (UnsupportedOperationException e) {\n    LOG.warn(\"Time conversion failed for class {}: {}\", value.getClass(), e.getMessage());\n    value = normalizeToTime(value); // fallback conversion\n}","preventionTips":["Map TIME fields only from Number/Duration/String/LocalTime inputs","Verify JDBC/CDC driver time object classes before relying on defaults","Fix schema mismatches where string columns feed TIME targets"],"tags":["java","type-conversion","time","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"}