{"record":{"id":"20da193082c15b51","repo":"prestodb/presto","slug":"invalid-time-s","errorCode":null,"errorMessage":"Invalid time '%s'","messagePattern":"Invalid time '(.+?)'","errorType":"error_code","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"presto-main-base/src/main/java/com/facebook/presto/util/DateTimeUtils.java","lineNumber":420,"sourceCode":"    public static String printTimeWithoutTimeZone(TimeZoneKey timeZoneKey, long value)\n    {\n        return TIME_FORMATTER.withZone(getDateTimeZone(timeZoneKey)).print(value);\n    }\n\n    public static boolean timeHasTimeZone(String value)\n    {\n        try {\n            try {\n                parseTimeWithTimeZone(value);\n                return true;\n            }\n            catch (RuntimeException e) {\n                parseTimeWithoutTimeZone(value);\n                return false;\n            }\n        }\n        catch (RuntimeException e) {\n            throw new IllegalArgumentException(format(\"Invalid time '%s'\", value));\n        }\n    }\n\n    private static final int YEAR_FIELD = 0;\n    private static final int MONTH_FIELD = 1;\n    private static final int DAY_FIELD = 3;\n    private static final int HOUR_FIELD = 4;\n    private static final int MINUTE_FIELD = 5;\n    private static final int SECOND_FIELD = 6;\n    private static final int MILLIS_FIELD = 7;\n\n    private static final PeriodFormatter INTERVAL_DAY_SECOND_FORMATTER = cretePeriodFormatter(IntervalField.DAY, IntervalField.SECOND);\n    private static final PeriodFormatter INTERVAL_DAY_MINUTE_FORMATTER = cretePeriodFormatter(IntervalField.DAY, IntervalField.MINUTE);\n    private static final PeriodFormatter INTERVAL_DAY_HOUR_FORMATTER = cretePeriodFormatter(IntervalField.DAY, IntervalField.HOUR);\n    private static final PeriodFormatter INTERVAL_DAY_FORMATTER = cretePeriodFormatter(IntervalField.DAY, IntervalField.DAY);\n\n    private static final PeriodFormatter INTERVAL_HOUR_SECOND_FORMATTER = cretePeriodFormatter(IntervalField.HOUR, IntervalField.SECOND);\n    private static final PeriodFormatter INTERVAL_HOUR_MINUTE_FORMATTER = cretePeriodFormatter(IntervalField.HOUR, IntervalField.MINUTE);","sourceCodeStart":402,"sourceCodeEnd":438,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-main-base/src/main/java/com/facebook/presto/util/DateTimeUtils.java#L402-L438","documentation":"DateTimeUtils.timeHasTimeZone parses a TIME literal to determine whether it includes a time-zone offset. When the value matches neither the time-with-tz nor the time-without-tz formatter, the underlying parse exception is replaced by an IllegalArgumentException formatting the bad value into \"Invalid time '%s'\".","triggerScenarios":"Passing a malformed time string (e.g. '25:00:00', '12:00', 'noon', or a full timestamp string) to APIs that classify time literals, such as parsing TIME literals in SQL or type coercion paths.","commonSituations":"Users writing '12:30 PM' style times in SQL; accidentally passing a timestamp where a time is expected; locale formats with AM/PM or fractional fields in the wrong place; leading/trailing whitespace.","solutions":["Use the canonical format 'HH:mm:ss[.fff]' e.g. '12:30:00.000' or with offset '12:30:00 +01:00'","Use try_cast(value AS TIME) to surface NULLs instead of exceptions","Trim/normalize the string before parsing and validate with a regex like ^\\\\d{2}:\\\\d{2}:\\\\d{2}","If you have a full timestamp, strip the date portion first"],"exampleFix":"-- before\nSELECT TIME '12:30 PM';\n-- after\nSELECT TIME '12:30:00.000';","handlingStrategy":"validation","validationCode":"boolean ok = value != null && value.matches(\"\\\\d{1,2}:\\\\d{2}:\\\\d{2}(\\\\.\\\\d{1,3})?([+-]\\\\d{2}:?\\\\d{2})? *$\");","typeGuard":null,"tryCatchPattern":"try { DateTimeUtils.timeHasTimeZone(value); } catch (IllegalArgumentException e) { return null; }","preventionTips":["Use 24-hour 'HH:mm:ss[.SSS]' format only","Strip date portions before passing to TIME parsers","Use try_cast(value AS TIME) to surface NULLs instead of exceptions"],"tags":["presto","time","parsing","datetime"],"backgroundTag":"invalid-time-format","analyzedSha":"55bb57d202de3b926896fa966c2c4a44c779634e","analyzedAt":"2026-09-04T12:50:26.162Z","contentChangedAt":"2026-09-04T12:50:26.162Z","schemaVersion":2},"datasetVersion":"2026-09-11T21:17:09.523Z"}