apache/seatunnel · error · UnsupportedOperationException

Unsupported convert ${value.getClass()} to LocalDateTime, ty

Error message

Unsupported convert ${value.getClass()} to LocalDateTime, typeDefine: ${typeDefine}

What it means

The typeDefine-aware convertLocalDateTime supports LocalDateTime, LocalDate, Date, String (parsed), and Number (epoch millis) inputs; any other class throws this UnsupportedOperationException. typeDefine is included to show the target timestamp type. It means the value on the TIMESTAMP conversion path has an unsupported runtime type.

Source

Thrown at seatunnel-api/src/main/java/org/apache/seatunnel/api/table/converter/BasicDataConverter.java:434

        if (value instanceof Date) {
            return convertLocalDateTime(typeDefine, (Date) value);
        }
        if (value instanceof LocalDate) {
            return convertLocalDateTime((LocalDate) value);
        }
        if (value instanceof java.sql.Date) {
            return convertLocalDateTime((java.sql.Date) value);
        }
        if (value instanceof java.sql.Timestamp) {
            return convertLocalDateTime((java.sql.Timestamp) value);
        }
        if (value instanceof String) {
            return convertLocalDateTime(typeDefine, (String) value);
        }
        if (value instanceof Number) {
            return convertLocalDateTime(typeDefine, (Number) value);
        }
        throw new UnsupportedOperationException(
                "Unsupported convert "
                        + value.getClass()
                        + " to LocalDateTime, typeDefine: "
                        + typeDefine);
    }

    default OffsetDateTime convertOffsetDateTime(T typeDefine, Object value)
            throws UnsupportedOperationException {
        if (value instanceof OffsetDateTime) {
            return (OffsetDateTime) value;
        }
        if (value instanceof LocalDateTime) {
            return ((LocalDateTime) value).atZone(ZoneId.systemDefault()).toOffsetDateTime();
        }
        if (value instanceof Instant) {
            return ((Instant) value).atZone(ZoneId.systemDefault()).toOffsetDateTime();
        }
        if (value instanceof java.sql.Date) {

View on GitHub (pinned to cf67b549a7)

Solutions

  1. Convert the value to LocalDateTime first, e.g. LocalDateTime.ofInstant(instant, ZoneOffset.UTC) or timestamp.toLocalDateTime().
  2. If the value is a numeric epoch in a String, parse it to long and pass the Number form so it is treated as epoch millis.
  3. Override convertLocalDateTime in a converter subclass to support the offending temporal type.
  4. Confirm the unit of the epoch value (millis vs micros vs seconds) and normalize before conversion.

Example fix

// before
converter.convertLocalDateTime(typeDefine, instant);
// after
converter.convertLocalDateTime(typeDefine, LocalDateTime.ofInstant(instant, ZoneId.systemDefault()));
Defensive patterns

Strategy: type-guard

Validate before calling

if (!(value instanceof LocalDateTime) && !(value instanceof LocalDate) && !(value instanceof java.util.Date)
    && !(value instanceof String) && !(value instanceof Number)) {
    throw new IllegalArgumentException("Unsupported temporal type: " + value.getClass());
}

Type guard

boolean isLocalDateTimeConvertible(Object v) {
    return v instanceof LocalDateTime || v instanceof LocalDate || v instanceof java.util.Date
        || v instanceof String || v instanceof Number;
}

Try / catch

try {
    return converter.convertLocalDateTime(typeDefine, value);
} catch (UnsupportedOperationException e) {
    LOG.warn("Temporal conversion failed for {}: {}", value.getClass(), e.getMessage());
    return null;
}

Prevention

When it happens

Trigger: Calling convertLocalDateTime(typeDefine, value) — or convert(...) with a TIMESTAMP SqlType — with a java.sql.Timestamp, Instant, OffsetDateTime, Calendar, Long-as-String, or other unsupported temporal object.

Common situations: JDBC returning java.sql.Timestamp (subclass nuance) or the driver's own datetime wrapper; deserialized epoch values as Strings; microsecond-precision objects (Instant) that the converter does not handle.

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


AI-assisted analysis of apache/seatunnel@cf67b549a7 (2026-09-10). Data as JSON: /api/errors/5c0a29ed4622736e. Report an issue: GitHub.