apache/shardingsphere · error · UnsupportedSQLOperationException
Unsupported time format: [%s]
Error message
Unsupported time format: [%s]
What it means
PostgreSQLTimeValueParser.parse attempts to read a LocalTime with a flexible formatter covering HH:mm:ss / HHmmss / HH:mm / HHmm plus optional fractional seconds and offsets. If DateTimeParseException occurs, it throws UnsupportedSQLOperationException 'Unsupported time format: [value]'. It fires when a text bind parameter for a time column matches none of the accepted time patterns.
Source
Thrown at database/protocol/dialect/postgresql/src/main/java/org/apache/shardingsphere/database/protocol/postgresql/packet/command/query/extended/bind/protocol/text/impl/PostgreSQLTimeValueParser.java:43
import java.time.format.DateTimeParseException;
/**
* Time value parser of PostgreSQL.
*/
public final class PostgreSQLTimeValueParser implements PostgreSQLTextValueParser<LocalTime> {
private static final DateTimeFormatter POSTGRESQL_TIME_FORMATTER = DateTimeFormatter.ofPattern(
"[HH:mm:ss][HHmmss][HH:mm][HHmm]"
+ "[.SSSSSSSSS][.SSSSSSSS][.SSSSSSS][.SSSSSS][.SSSSS][.SSSS][.SSS][.SS][.S]"
+ "[ ]"
+ "[XXXXX][XXXX][XXX][XX][X]");
@Override
public LocalTime parse(final String value) {
try {
return POSTGRESQL_TIME_FORMATTER.parse(value, LocalTime::from);
} catch (final DateTimeParseException ignored) {
throw new UnsupportedSQLOperationException("Unsupported time format: [" + value + "]");
}
}
}
View on GitHub (pinned to e952770a21)
Solutions
- Use one of the accepted patterns: HH:mm:ss, HHmmss, HH:mm, HHmm (optionally .fractional and zone offset)
- Bind a java.time.LocalTime / java.sql.Time typed parameter instead of a string
- Pre-validate with LocalTime.parse before sending the value
- Normalize clock strings at the application boundary (drop AM/PM text, clamp values)
Example fix
// before
stmt.setString(1, "12:00 PM");
// after
stmt.setTime(1, java.sql.Time.valueOf("12:00:00")); Defensive patterns
Strategy: validation
Validate before calling
try { java.time.LocalTime.parse(value, java.time.format.DateTimeFormatter.ofPattern("[HH:mm:ss][HHmmss][HH:mm][HHmm]")); return true; } catch (Exception e) { return false; } Try / catch
catch (UnsupportedSQLOperationException e) { if (e.getMessage().startsWith("Unsupported time format")) { /* normalize and retry with a standard pattern */ } } Prevention
- Send times as HH:mm:ss
- Use setTime(LocalTime/Time) typed parameters
- Reject free-text clock strings in input validation
When it happens
Trigger: Binding values like '12 noon', '25:99:00' (out-of-range), 'noon', an empty string, or a format with stray separators during extended-protocol bind for a time parameter.
Common situations: Applications binding free-text time strings, 24h+ hour values, locale-specific time text, or trailing garbage the optional-offset section cannot absorb.
Related errors
- Underlying SQL state: %s, underlying error code: %s.
- Underlying SQL state: %s, underlying error code: %s.
- Underlying SQL state: %s, underlying error code: %s.
- Underlying SQL state: %s, underlying error code: %s.
- Underlying SQL state: %s, underlying error code: %s.
AI-assisted analysis of apache/shardingsphere@e952770a21 (2026-08-14).
Data as JSON: /api/errors/b7b727d713103b8e.
Report an issue: GitHub.