apache/seatunnel · error · RuntimeException
Cannot convert date:
Error message
Cannot convert date:
What it means
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.
Source
Thrown at seatunnel-connectors-v2/connector-iceberg/src/main/java/org/apache/seatunnel/connectors/seatunnel/iceberg/data/RowConverter.java:399
return (ByteBuffer) value;
}
throw new IllegalArgumentException(
"Cannot convert to binary: " + value.getClass().getName());
}
protected LocalDate convertDateValue(Object value) {
if (value instanceof Number) {
int days = ((Number) value).intValue();
return DateTimeUtil.dateFromDays(days);
} else if (value instanceof String) {
return LocalDate.parse((String) value);
} else if (value instanceof LocalDate) {
return (LocalDate) value;
} else if (value instanceof Date) {
int days = (int) (((Date) value).getTime() / 1000 / 60 / 60 / 24);
return DateTimeUtil.dateFromDays(days);
}
throw new RuntimeException("Cannot convert date: " + value);
}
protected LocalTime convertTimeValue(Object value) {
if (value instanceof Number) {
long millis = ((Number) value).longValue();
return DateTimeUtil.timeFromMicros(millis * 1000);
} else if (value instanceof String) {
return LocalTime.parse((String) value);
} else if (value instanceof LocalTime) {
return (LocalTime) value;
} else if (value instanceof Date) {
long millis = ((Date) value).getTime();
return DateTimeUtil.timeFromMicros(millis * 1000);
}
throw new RuntimeException("Cannot convert time: " + value);
}
protected Temporal convertTimestampValue(Object value, Types.TimestampType type) {View on GitHub (pinned to cf67b549a7)
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).
Example fix
// before
writer.write(idx, "2024-01-15"); // String not accepted
// after
writer.write(idx, LocalDate.parse("2024-01-15")); // LocalDate accepted Defensive patterns
Strategy: type-guard
Validate before calling
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())); Type guard
boolean isDateConvertible(Object v) { return v instanceof Number || v instanceof LocalDate || v instanceof java.util.Date; } Try / catch
try { sink.write(row); } catch (RuntimeException e) { if (e.getMessage() != null && e.getMessage().startsWith("Cannot convert date")) { /* parse string or DLQ */ } else throw e; } Prevention
- 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
When it happens
Trigger: convertDateValue receives e.g. a String '2024-01-01', LocalDateTime, or Temporal while mapping to an Iceberg DATE column.
Common situations: 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.
Understand the failure class
Background: Type mismatch errors: IllegalArgumentException, TypeError and type guards across 150 open-source libraries — this error's family across 150 libraries.
Related errors
- Cannot convert to BigDecimal:
- Cannot convert to boolean:
- Cannot convert to UUID:
- Cannot convert to binary:
- Cannot convert time:
AI-assisted analysis of apache/seatunnel@cf67b549a7 (2026-09-10).
Data as JSON: /api/errors/49dbf0fc458683ab.
Report an issue: GitHub.