{"record":{"id":"b7b727d713103b8e","repo":"apache/shardingsphere","slug":"unsupported-time-format-s","errorCode":null,"errorMessage":"Unsupported time format: [%s]","messagePattern":"Unsupported time format: \\[(.+?)\\]","errorType":"exception","errorClass":"UnsupportedSQLOperationException","httpStatus":null,"severity":"error","filePath":"database/protocol/dialect/postgresql/src/main/java/org/apache/shardingsphere/database/protocol/postgresql/packet/command/query/extended/bind/protocol/text/impl/PostgreSQLTimeValueParser.java","lineNumber":43,"sourceCode":"import java.time.format.DateTimeParseException;\n\n/**\n * Time value parser of PostgreSQL.\n */\npublic final class PostgreSQLTimeValueParser implements PostgreSQLTextValueParser<LocalTime> {\n    \n    private static final DateTimeFormatter POSTGRESQL_TIME_FORMATTER = DateTimeFormatter.ofPattern(\n            \"[HH:mm:ss][HHmmss][HH:mm][HHmm]\"\n                    + \"[.SSSSSSSSS][.SSSSSSSS][.SSSSSSS][.SSSSSS][.SSSSS][.SSSS][.SSS][.SS][.S]\"\n                    + \"[ ]\"\n                    + \"[XXXXX][XXXX][XXX][XX][X]\");\n    \n    @Override\n    public LocalTime parse(final String value) {\n        try {\n            return POSTGRESQL_TIME_FORMATTER.parse(value, LocalTime::from);\n        } catch (final DateTimeParseException ignored) {\n            throw new UnsupportedSQLOperationException(\"Unsupported time format: [\" + value + \"]\");\n        }\n    }\n}\n","sourceCodeStart":25,"sourceCodeEnd":47,"githubUrl":"https://github.com/apache/shardingsphere/blob/e952770a215630a3659c75d64369168cd3e26b82/database/protocol/dialect/postgresql/src/main/java/org/apache/shardingsphere/database/protocol/postgresql/packet/command/query/extended/bind/protocol/text/impl/PostgreSQLTimeValueParser.java#L25-L47","documentation":"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.","triggerScenarios":"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.","commonSituations":"Applications binding free-text time strings, 24h+ hour values, locale-specific time text, or trailing garbage the optional-offset section cannot absorb.","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)"],"exampleFix":"// before\nstmt.setString(1, \"12:00 PM\");\n// after\nstmt.setTime(1, java.sql.Time.valueOf(\"12:00:00\"));","handlingStrategy":"validation","validationCode":"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; }","typeGuard":null,"tryCatchPattern":"catch (UnsupportedSQLOperationException e) { if (e.getMessage().startsWith(\"Unsupported time format\")) { /* normalize and retry with a standard pattern */ } }","preventionTips":["Send times as HH:mm:ss","Use setTime(LocalTime/Time) typed parameters","Reject free-text clock strings in input validation"],"tags":["postgresql","bind","time","value-parsing"],"backgroundTag":null,"analyzedSha":"e952770a215630a3659c75d64369168cd3e26b82","analyzedAt":"2026-08-14T13:54:53.392Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}