apache/seatunnel · error · UnsupportedOperationException

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

Error message

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

What it means

This parameterless convertLocalDateTime overload accepts LocalDateTime, String, and Number inputs and throws UnsupportedOperationException for any other class, without a typeDefine in the message. It is the legacy/typed-less variant of error 87 and indicates the temporal conversion path received an unsupported object.

Source

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

        if (value instanceof Date) {
            return convertLocalDateTime((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((String) value);
        }
        if (value instanceof Number) {
            return convertLocalDateTime((Number) value);
        }
        throw new UnsupportedOperationException(
                "Unsupported convert " + value.getClass() + " to LocalDateTime");
    }

    default OffsetDateTime convertOffsetDateTime(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) {
            return ((java.sql.Date) value)
                    .toLocalDate()
                    .atTime(LocalTime.MIDNIGHT)

View on GitHub (pinned to cf67b549a7)

Solutions

  1. Switch to the typeDefine-aware overload convertLocalDateTime(typeDefine, value) which handles more input types (LocalDate, Date, etc.).
  2. Convert explicitly: for Instant use LocalDateTime.ofInstant(instant, zoneId); for java.sql.Timestamp use ts.toLocalDateTime().
  3. Override convertLocalDateTime in a converter subclass to accept the offending type.
  4. If the source is a String, ensure it is parseable as a date-time before calling, or pre-parse with LocalDateTime.parse.

Example fix

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

Strategy: type-guard

Validate before calling

if (!(value instanceof LocalDateTime) && !(value instanceof String) && !(value instanceof Number)) {
    throw new IllegalArgumentException("convertLocalDateTime(Object) accepts only LocalDateTime/String/Number, got " + value.getClass());
}

Type guard

boolean isSimpleLocalDateTimeInput(Object v) {
    return v instanceof LocalDateTime || v instanceof String || v instanceof Number;
}

Try / catch

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

Prevention

When it happens

Trigger: Calling convertLocalDateTime(Object value) directly with Instant, java.util.Date, java.sql.Timestamp, OffsetDateTime, Calendar, or a non-numeric String.

Common situations: Mixing the two convertLocalDateTime overloads — assuming the parameterless one is as permissive; framework date wrappers from ORMs or drivers; epoch values boxed as BigDecimal instead of a handled Number subtype (BigDecimal is a Number, but exotic wrappers may not be).

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/13602ea08a398f95. Report an issue: GitHub.