apache/seatunnel · error · UnsupportedOperationException

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

Error message

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

What it means

The no-typeDefine variant of convertTime accepts Number, Duration, LocalTime-like and String values; anything else triggers UnsupportedOperationException naming the value's class. It signals the converter received a field type it has no LocalTime conversion rule for.

Source

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

        if (value instanceof Time) {
            return convertLocalTime((Time) value);
        }
        if (value instanceof LocalDateTime) {
            return convertLocalTime((LocalDateTime) value);
        }
        if (value instanceof java.sql.Timestamp) {
            return convertLocalTime((java.sql.Timestamp) value);
        }
        if (value instanceof String) {
            return convertLocalTime((String) value);
        }
        if (value instanceof Number) {
            return convertLocalTime((Number) value);
        }
        if (value instanceof Duration) {
            return convertLocalTime((Duration) value);
        }
        throw new UnsupportedOperationException(
                "Unsupported convert " + value.getClass() + " to LocalTime");
    }

    default LocalTime convertLocalTime(LocalDateTime value) {
        return value.toLocalTime();
    }

    default LocalTime convertLocalTime(Time value) {
        return value.toLocalTime();
    }

    default LocalTime convertLocalTime(java.sql.Timestamp value) {
        return LocalTime.of(
                value.getHours(), value.getMinutes(), value.getSeconds(), value.getNanos());
    }

    default LocalTime convertLocalTime(Date value) {
        long millis = (int) (value.getTime() % TimeUnit.SECONDS.toMillis(1));

View on GitHub (pinned to cf67b549a7)

Solutions

  1. Convert the value to LocalTime, Duration, Number (nanos of day), or an ISO-8601 time String before calling convert
  2. Inspect the class named in the message and add a custom converter branch for it
  3. Fix the schema/source mapping so the deserialized type matches the TIME column expectations

Example fix

// before
converter.convert(calendarObj); // throws
// after
LocalTime t = ((java.util.Calendar) calendarObj).toInstant().atZone(ZoneId.systemDefault()).toLocalTime();
converter.convert(t);
Defensive patterns

Strategy: type-guard

Validate before calling

if (!(v instanceof Number) && !(v instanceof String) && !(v instanceof java.time.Duration) && !(v instanceof java.time.LocalTime)) {
    throw new IllegalStateException("Unsupported time class: " + v.getClass());
}

Type guard

boolean isConvertibleToTime(Object v) {
    return v instanceof Number || v instanceof String
        || v instanceof java.time.Duration || v instanceof java.time.LocalTime;
}

Try / catch

try {
    converter.convert(value);
} catch (UnsupportedOperationException e) {
    LOG.warn("Time convert failed, class={}", value.getClass(), e);
    value = normalizeToTime(value);
}

Prevention

When it happens

Trigger: Calling convert()/convertTime(Object) with e.g. java.util.Calendar, char[], or a domain object for a TIME column, where the value is not a Number, Duration, or parseable String.

Common situations: Custom source connectors passing raw driver objects; upstream format changes (Avro/Protobuf time logical types materialized as custom classes); accidentally passing a full timestamp object where a plain time was expected.

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/5e539a37ae0db0b1. Report an issue: GitHub.