apache/seatunnel · error · DateTimeParseException
Unable to parse OffsetDateTime from string:
Error message
Unable to parse OffsetDateTime from string:
What it means
parseOffsetDateTimeFromString attempts ISO OffsetDateTime parsing, then several fallback formats, then ZonedDateTime conversion. If none succeed it throws DateTimeParseException with the input string. This is the low-level parsing failure usually surfaced (wrapped) by getOffsetDateTime.
Source
Thrown at seatunnel-connectors-v2/connector-jdbc/src/main/java/org/apache/seatunnel/connectors/seatunnel/jdbc/utils/JdbcFieldTypeUtils.java:295
}
// Try parsing as standard ISO-8601 OffsetDateTime
OffsetDateTime directParsed = tryParseOffsetDateTime(trimmed);
if (directParsed != null) {
return directParsed;
}
// Normalize common relaxed forms and try again
String normalized = normalizeOffsetDateTimeString(trimmed);
OffsetDateTime normalizedParsed = tryParseOffsetDateTime(normalized);
if (normalizedParsed != null) {
return normalizedParsed;
}
// Finally, try parsing as ZonedDateTime and convert to OffsetDateTime
OffsetDateTime zonedParsed = tryParseZonedDateTime(trimmed);
if (zonedParsed != null) {
return zonedParsed;
}
throw new DateTimeParseException(
"Unable to parse OffsetDateTime from string: " + str, trimmed, 0);
}
private static OffsetDateTime tryParseOffsetDateTime(String value) {
try {
return OffsetDateTime.parse(value);
} catch (DateTimeParseException ignore) {
return null;
}
}
private static OffsetDateTime tryParseZonedDateTime(String value) {
try {
return ZonedDateTime.parse(value).toOffsetDateTime();
} catch (DateTimeParseException ignore) {
return null;
}
}View on GitHub (pinned to cf67b549a7)
Solutions
- Inspect the message to see the exact string that failed, then normalize the format in SQL (STR_TO_DATE / TO_TIMESTAMP) before it reaches the reader
- Cast or map the column to a native timestamp type so no string parsing occurs
- Upgrade SeaTunnel for broader format support, or contribute/extend tryParse* methods for the needed format
- If the data has no zone info, decide an offset explicitly and format with one (e.g. append '+00:00')
Example fix
// before SELECT created_at FROM logs // '2024-01-01 10:00:00' // after SELECT DATE_FORMAT(created_at, '%Y-%m-%dT%H:%i:%s+00:00') AS created_at FROM logs // ISO-8601 with offset
Defensive patterns
Strategy: type-guard
Validate before calling
try {
java.time.OffsetDateTime.parse(value.trim());
} catch (java.time.format.DateTimeParseException e) {
// normalize or reject before sending to connector
value = java.time.LocalDateTime.parse(value.trim()).atOffset(java.time.ZoneOffset.UTC).toString();
} Type guard
boolean isIsoOffsetDateTime(String s) {
try { java.time.OffsetDateTime.parse(s.trim()); return true; }
catch (Exception e) { return false; }
} Try / catch
try {
OffsetDateTime odt = parse(str);
} catch (DateTimeParseException e) {
log.error("Unparseable timestamp string '{}' — normalize format upstream", str);
} Prevention
- Store temporal values in native timestamp columns, not VARCHAR
- Use ISO-8601 with explicit offset when strings are unavoidable
- Normalize vendor formats in SQL before reading
When it happens
Trigger: getOffsetDateTime passes a trimmed string that matches no supported pattern: missing timezone offset, non-ISO separators/formats, localized month names, epoch-style numbers, etc.
Common situations: Vendor-specific timestamp text formats (MySQL, Oracle) reaching the parser; values like '2024-01-01 10:00:00.0' with no zone; user data stored as strings in VARCHAR columns being read as timestamps.
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
- Failed to parse OffsetDateTime value: (class: )
- 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/79e3cd6ec114d57a.
Report an issue: GitHub.