{"record":{"id":"49dbf0fc458683ab","repo":"apache/seatunnel","slug":"cannot-convert-date","errorCode":null,"errorMessage":"Cannot convert date: ","messagePattern":"Cannot convert date: ","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":399,"sourceCode":"            return (ByteBuffer) value;\n        }\n        throw new IllegalArgumentException(\n                \"Cannot convert to binary: \" + value.getClass().getName());\n    }\n\n    protected LocalDate convertDateValue(Object value) {\n        if (value instanceof Number) {\n            int days = ((Number) value).intValue();\n            return DateTimeUtil.dateFromDays(days);\n        } else if (value instanceof String) {\n            return LocalDate.parse((String) value);\n        } else if (value instanceof LocalDate) {\n            return (LocalDate) value;\n        } else if (value instanceof Date) {\n            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) {","sourceCodeStart":381,"sourceCodeEnd":417,"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#L381-L417","documentation":"Iceberg RowConverter throws this RuntimeException when a date column value is not a Number (epoch days), LocalDate, or java.util.Date. convertDateValue only handles those representations; other objects (e.g. String, LocalDateTime) are rejected with the raw value in the message.","triggerScenarios":"convertDateValue receives e.g. a String '2024-01-01', LocalDateTime, or Temporal while mapping to an Iceberg DATE column.","commonSituations":"String-formatted dates from CSV/JSON sources mapped directly to DATE columns; LocalDateTime values produced for a DATE column after schema change; custom sources returning String dates.","solutions":["Convert the value to LocalDate or epoch-day Number before the sink.","Add a transform CAST(column, DATE) so SeaTunnel delivers a proper date value.","If the value is a String date, parse it upstream: LocalDate.parse(str)."],"exampleFix":"// before\nwriter.write(idx, \"2024-01-15\"); // String not accepted\n// after\nwriter.write(idx, LocalDate.parse(\"2024-01-15\")); // LocalDate accepted","handlingStrategy":"type-guard","validationCode":"if (!(v instanceof Number) && !(v instanceof LocalDate) && !(v instanceof java.util.Date)) throw new IllegalArgumentException(\"date column must be Number/LocalDate/Date, got \" + (v == null ? \"null\" : v.getClass().getName()));","typeGuard":"boolean isDateConvertible(Object v) { return v instanceof Number || v instanceof LocalDate || v instanceof java.util.Date; }","tryCatchPattern":"try { sink.write(row); } catch (RuntimeException e) { if (e.getMessage() != null && e.getMessage().startsWith(\"Cannot convert date\")) { /* parse string or DLQ */ } else throw e; }","preventionTips":["CAST string dates to SeaTunnel DateType in a transform","Never map String columns directly to Iceberg DATE","Smoke-test type mapping with one row before full ingestion"],"tags":["iceberg","type-conversion","date","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"}