apache/seatunnel · error · SQLException
Failed to parse OffsetDateTime value: (class: )
Error message
Failed to parse OffsetDateTime value: (class: )
What it means
JdbcFieldTypeUtils.getOffsetDateTime converts arbitrary JDBC objects to OffsetDateTime. When the object is not directly an OffsetDateTime/Timestamp, it stringifies it and tries to parse; a parse failure is wrapped in a SQLException carrying the string value and the source object's class. It means the driver returned a temporal type in a format the utility cannot interpret.
Source
Thrown at seatunnel-connectors-v2/connector-jdbc/src/main/java/org/apache/seatunnel/connectors/seatunnel/jdbc/utils/JdbcFieldTypeUtils.java:261
// Fall back to ResultSet.getTimestamp() which the Oracle JDBC driver converts correctly.
String objClassName = obj.getClass().getName();
if (objClassName.equals("oracle.sql.TIMESTAMPLTZ")
|| objClassName.equals("oracle.sql.TIMESTAMPTZ")) {
Timestamp oracleTs =
resultSet.getTimestamp(
columnIndex, Calendar.getInstance(TimeZone.getTimeZone("UTC")));
if (oracleTs == null) {
return null;
}
return oracleTs.toInstant().atOffset(ZoneOffset.UTC);
}
// Try to parse as string
String str = obj.toString();
try {
return parseOffsetDateTimeFromString(str);
} catch (Exception e) {
throw new SQLException(
"Failed to parse OffsetDateTime value: "
+ str
+ " (class: "
+ obj.getClass().getName()
+ ")",
e);
}
}
public static OffsetDateTime parseOffsetDateTimeFromString(String str)
throws DateTimeParseException {
String trimmed = str.trim();
// Treat empty string as "no value"
if (trimmed.isEmpty()) {
return null;
}
// Try parsing as standard ISO-8601 OffsetDateTime
OffsetDateTime directParsed = tryParseOffsetDateTime(trimmed);View on GitHub (pinned to cf67b549a7)
Solutions
- Check the value and class in the message to see the offending format, then adjust the query to CAST the column to a standard timestamp-with-time-zone type
- Upgrade SeaTunnel or the JDBC driver — newer versions add more recognized formats
- Add handling in JdbcFieldTypeUtils for the offending class/format if you control the build
- Convert in the SQL (e.g. TO_TIMESTAMP_TZ / CONVERT_TZ) so the driver returns a parseable type
Example fix
// before SELECT ts FROM events // returns '2024-01-01 10:00:00' string-ish // after SELECT CAST(ts AS TIMESTAMP WITH TIME ZONE) AS ts FROM events
Defensive patterns
Strategy: type-guard
Validate before calling
Object v = rs.getObject(col);
if (!(v instanceof java.time.OffsetDateTime) && !(v instanceof java.sql.Timestamp)) {
log.warn("Column {} returns {} — add CAST to TIMESTAMP WITH TIME ZONE", col, v.getClass().getName());
} Type guard
boolean isOffsetDateTimeSafe(Object o) {
return o instanceof java.time.OffsetDateTime || o instanceof java.sql.Timestamp;
} Try / catch
try {
OffsetDateTime odt = JdbcFieldTypeUtils.getOffsetDateTime(obj);
} catch (SQLException e) {
if (e.getMessage().startsWith("Failed to parse OffsetDateTime value")) {
log.warn("Falling back to Timestamp->toInstant conversion for value: {}", e.getMessage());
}
} Prevention
- CAST temporal columns to standard SQL timestamp-with-time-zone types
- Pin driver versions with predictable getObject() mappings
- Spot-check unusual columns' runtime classes before full runs
When it happens
Trigger: Reading a column whose JDBC value is not OffsetDateTime and whose toString() (e.g. '2024-01-01 10:00:00' without offset, or a driver-specific format) cannot be parsed by parseOffsetDateTimeFromString; typically from TIMESTAMP WITH TIME ZONE or nonstandard vendor types.
Common situations: Drivers returning unusual string formats (MySQL 'YYYY-MM-DD HH:mm:ss', Oracle TIMESTAMP WITH LOCAL TIME ZONE); reading into Object mappings with getObject() on exotic types; schema drift where a column changed type.
Understand the failure class
- Parsing and encoding errors: unexpected token, malformed input — why parsers reject input and how to find the real culprit.
Related errors
- Unable to parse OffsetDateTime from string:
- Unsupported datetime format:
- HOCON Config parse from %s failed.
- Unsupported parse SeaTunnel Type from '%s'.
- Cannot get split '%s' to get databaseName and tableName
AI-assisted analysis of apache/seatunnel@cf67b549a7 (2026-09-10).
Data as JSON: /api/errors/4393b0a28139483e.
Report an issue: GitHub.