{"record":{"id":"ab74907e61c33fcb","repo":"prestodb/presto","slug":"invalid-day-time-interval","errorCode":null,"errorMessage":"Invalid day-time interval: ","messagePattern":"Invalid day-time interval: ","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"presto-client/src/main/java/com/facebook/presto/client/IntervalDayTime.java","lineNumber":89,"sourceCode":"\n        return format(\"%s%d %02d:%02d:%02d.%03d\", sign, day, hour, minute, second, millis);\n    }\n\n    public static long parseMillis(String value)\n    {\n        if (value.equals(LONG_MIN_VALUE)) {\n            return Long.MIN_VALUE;\n        }\n\n        long signum = 1;\n        if (value.startsWith(\"-\")) {\n            signum = -1;\n            value = value.substring(1);\n        }\n\n        Matcher matcher = FORMAT.matcher(value);\n        if (!matcher.matches()) {\n            throw new IllegalArgumentException(\"Invalid day-time interval: \" + value);\n        }\n\n        long days = parseLong(matcher.group(1));\n        long hours = parseLong(matcher.group(2));\n        long minutes = parseLong(matcher.group(3));\n        long seconds = parseLong(matcher.group(4));\n        long millis = parseLong(matcher.group(5));\n\n        return toMillis(days, hours, minutes, seconds, millis) * signum;\n    }\n}\n","sourceCodeStart":71,"sourceCodeEnd":101,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-client/src/main/java/com/facebook/presto/client/IntervalDayTime.java#L71-L101","documentation":"IntervalDayTime.parseMillis parses a day-time interval string (e.g. '1 12:30:15.000') using the FORMAT regex. If the string does not match the expected '<days> <hours>:<minutes>:<seconds>' shape, this IllegalArgumentException is thrown with the offending value appended to the message.","triggerScenarios":"Calling IntervalDayTime.parseMillis (directly or via INTERVAL literals in the client) with a string that fails the FORMAT regex: wrong field order, missing seconds/milliseconds, extra whitespace, non-numeric fields, or a bare number without the 'd HH:mm:ss' layout.","commonSituations":"Users typing '5 days' or '36:00:00' instead of '1 12:00:00.000'; passing a year-month style string like '1-6' to a day-time parser; locale-formatted or whitespace-padded values coming from logs or user input.","solutions":["Check the input string matches the FORMAT pattern: [sign]days[ ]hours:minutes:seconds[.millis] (e.g. '1 02:03:04.000').","Normalize the value before parsing: trim whitespace, strip trailing 'days'/'day' text, and pad missing components to HH:mm:ss.","Wrap parseMillis in try-catch and surface a user-facing validation message showing the expected format.","Confirm the right parser is used: day-time values must go to IntervalDayTime, year-month values (e.g. '1-6') to IntervalYearMonth."],"exampleFix":"// before\nlong millis = IntervalDayTime.parseMillis(userInput); // throws on '5 days'\n// after\nString normalized = userInput.trim().matches(\".*(?i)days?\") ? userInput.trim().replaceAll(\"(?i)\\\\s*days?\", \"\") + \" 00:00:00.000\" : userInput.trim();\nlong millis = IntervalDayTime.parseMillis(normalized);","handlingStrategy":"validation","validationCode":"private static final Pattern INTERVAL_DAY_TIME = Pattern.compile(\"-?\\\\d+\\\\s*\\\\d{1,2}:\\\\d{2}:\\\\d{2}(\\\\.\\\\d{1,3})?\");\nif (value == null || !INTERVAL_DAY_TIME.matcher(value.trim()).matches()) {\n    throw new IllegalArgumentException(\"Expected day-time interval like '1 02:03:04.000', got: \" + value);\n}","typeGuard":null,"tryCatchPattern":"try { long ms = IntervalDayTime.parseMillis(value); } catch (IllegalArgumentException e) { /* show e.getMessage() with expected format */ }","preventionTips":["Validate interval strings against the regex before parsing","Normalize user input (trim, strip 'days' text, pad fields)","Use the correct parser per interval type (day-time vs year-month)","Wrap parsing at a single utility method so error messages are consistent"],"tags":["parsing","presto-client","illegal-argument","interval"],"backgroundTag":"invalid-interval-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"}