{"record":{"id":"cc4fafd1a1d141ce","repo":"apache/seatunnel","slug":"cannot-convert-time","errorCode":null,"errorMessage":"Cannot convert time: ","messagePattern":"Cannot convert time: ","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"seatunnel-connectors-v2/connector-iceberg/src/main/java/org/apache/seatunnel/connectors/seatunnel/iceberg/data/RowConverter.java","lineNumber":414,"sourceCode":"            int days = (int) (((Date) value).getTime() / 1000 / 60 / 60 / 24);\n            return DateTimeUtil.dateFromDays(days);\n        }\n        throw new RuntimeException(\"Cannot convert date: \" + value);\n    }\n\n    protected LocalTime convertTimeValue(Object value) {\n        if (value instanceof Number) {\n            long millis = ((Number) value).longValue();\n            return DateTimeUtil.timeFromMicros(millis * 1000);\n        } else if (value instanceof String) {\n            return LocalTime.parse((String) value);\n        } else if (value instanceof LocalTime) {\n            return (LocalTime) value;\n        } else if (value instanceof Date) {\n            long millis = ((Date) value).getTime();\n            return DateTimeUtil.timeFromMicros(millis * 1000);\n        }\n        throw new RuntimeException(\"Cannot convert time: \" + value);\n    }\n\n    protected Temporal convertTimestampValue(Object value, Types.TimestampType type) {\n        if (type.shouldAdjustToUTC()) {\n            return convertOffsetDateTime(value);\n        }\n        return convertLocalDateTime(value);\n    }\n\n    private OffsetDateTime convertOffsetDateTime(Object value) {\n        if (value instanceof Number) {\n            long millis = ((Number) value).longValue();\n            return DateTimeUtil.timestamptzFromMicros(millis * 1000);\n        } else if (value instanceof String) {\n            return parseOffsetDateTime((String) value);\n        } else if (value instanceof OffsetDateTime) {\n            return (OffsetDateTime) value;\n        } else if (value instanceof LocalDateTime) {","sourceCodeStart":396,"sourceCodeEnd":432,"githubUrl":"https://github.com/apache/seatunnel/blob/cf67b549a7a6c35fa0beb12d83c62892427ea919/seatunnel-connectors-v2/connector-iceberg/src/main/java/org/apache/seatunnel/connectors/seatunnel/iceberg/data/RowConverter.java#L396-L432","documentation":"Iceberg RowConverter throws this RuntimeException when a time column value is not a Number (millis/micros), LocalTime, or java.util.Date. convertTimeValue supports only those types; anything else is rejected with the raw value in the message.","triggerScenarios":"convertTimeValue receives e.g. a String '10:30:00', OffsetDateTime, or Duration while mapping to an Iceberg TIME column.","commonSituations":"String-formatted times from text-based sources (CSV/JSON); sources that encode time as OffsetDateTime; schema mismatch after upstream type changes.","solutions":["Convert the value to LocalTime before the sink.","Add a transform CAST(column, TIME) so the sink receives a supported type.","Parse string times upstream: LocalTime.parse(str)."],"exampleFix":"// before\nwriter.write(idx, \"10:30:00\"); // String not accepted\n// after\nwriter.write(idx, LocalTime.parse(\"10:30:00\")); // LocalTime accepted","handlingStrategy":"type-guard","validationCode":"if (!(v instanceof Number) && !(v instanceof LocalTime) && !(v instanceof java.util.Date)) throw new IllegalArgumentException(\"time column must be Number/LocalTime/Date, got \" + (v == null ? \"null\" : v.getClass().getName()));","typeGuard":"boolean isTimeConvertible(Object v) { return v instanceof Number || v instanceof LocalTime || v instanceof java.util.Date; }","tryCatchPattern":"try { sink.write(row); } catch (RuntimeException e) { if (e.getMessage() != null && e.getMessage().startsWith(\"Cannot convert time\")) { /* parse string or DLQ */ } else throw e; }","preventionTips":["CAST string times to SeaTunnel TimeType in a transform","Map source TIME logical types to SeaTunnel TimeType","Validate temporal column mappings in pipeline dry-runs"],"tags":["iceberg","type-conversion","time","sink"],"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"}