{"record":{"id":"7a1c8624d59150bf","repo":"MyCATApache/Mycat-Server","slug":"interval-string-does-not-match-day-time-format-of","errorCode":null,"errorMessage":"Interval string does not match day-time format of 'd h:m:s.n': ","messagePattern":"Interval string does not match day-time format of 'd h:m:s\\.n': ","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"src/main/java/io/mycat/memory/unsafe/types/CalendarInterval.java","lineNumber":145,"sourceCode":"      }\n    }\n    return result;\n  }\n\n  /**\n   * Parse dayTime string in form: [-]d HH:mm:ss.nnnnnnnnn\n   *\n   * adapted from HiveIntervalDayTime.valueOf\n   */\n  public static CalendarInterval fromDayTimeString(String s) throws IllegalArgumentException {\n    CalendarInterval result = null;\n    if (s == null) {\n      throw new IllegalArgumentException(\"Interval day-time string was null\");\n    }\n    s = s.trim();\n    Matcher m = dayTimePattern.matcher(s);\n    if (!m.matches()) {\n      throw new IllegalArgumentException(\n        \"Interval string does not match day-time format of 'd h:m:s.n': \" + s);\n    } else {\n      try {\n        int sign = m.group(1) != null && m.group(1).equals(\"-\") ? -1 : 1;\n        long days = toLongWithRange(\"day\", m.group(2), 0, Integer.MAX_VALUE);\n        long hours = toLongWithRange(\"hour\", m.group(3), 0, 23);\n        long minutes = toLongWithRange(\"minute\", m.group(4), 0, 59);\n        long seconds = toLongWithRange(\"second\", m.group(5), 0, 59);\n        // Hive allow nanosecond precision interval\n        long nanos = toLongWithRange(\"nanosecond\", m.group(7), 0L, 999999999L);\n        result = new CalendarInterval(0, sign * (\n          days * MICROS_PER_DAY + hours * MICROS_PER_HOUR + minutes * MICROS_PER_MINUTE +\n          seconds * MICROS_PER_SECOND + nanos / 1000L));\n      } catch (Exception e) {\n        throw new IllegalArgumentException(\n          \"Error parsing interval day-time string: \" + e.getMessage(), e);\n      }\n    }","sourceCodeStart":127,"sourceCodeEnd":163,"githubUrl":"https://github.com/MyCATApache/Mycat-Server/blob/65f8d8beb752f935752f2a0eec0ab017facab9ef/src/main/java/io/mycat/memory/unsafe/types/CalendarInterval.java#L127-L163","documentation":"Thrown by CalendarInterval.fromDayTimeString when the trimmed input is non-null but does not match dayTimePattern, i.e. it is not of the form [-]d HH:mm:ss.nnnnnnnnn. This is a format validation guard: the string was present but syntactically invalid (missing time parts, bad separators, non-numeric fields, etc.). The message includes the offending input so callers can see exactly which value failed; fix by supplying a day-time interval string like '3 12:30:45.123'.","triggerScenarios":"Calling fromDayTimeString with strings like \"1 day\", \"12:30\", \"1 12:30:45.123.456\", \"01:02:03\" (no day part).","commonSituations":"Interval literals copied from PostgreSQL/Hive in a different syntax, missing time components, extra sub-second digits, locale-formatted durations.","solutions":["Rewrite the literal as 'd h:m:s.n', e.g. '1 12:30:45.123'","Drop unsupported extra precision (max 9 nanosecond digits)","Trim whitespace and remove surrounding quotes before parsing"],"exampleFix":"// before\nCalendarInterval iv = CalendarInterval.fromDayTimeString(\"1 day 12 hours\");\n// after\nCalendarInterval iv = CalendarInterval.fromDayTimeString(\"1 12:00:00.000\");","handlingStrategy":"validation","validationCode":"private static final Pattern DT = Pattern.compile(\"^-?\\\\d+ \\\\d{1,2}:\\\\d{1,2}:\\\\d{1,2}\\\\.\\\\d{1,9}$\");\nstatic void requireDayTime(String s) {\n  if (s == null || !DT.matcher(s.trim()).matches())\n    throw new IllegalArgumentException(\"expected 'd h:m:s.n', got: \" + s);\n}","typeGuard":"static boolean isDayTimeString(String s) {\n  return s != null && s.trim().matches(\"-?\\\\d+ \\\\d{1,2}:\\\\d{1,2}:\\\\d{1,2}(\\\\.\\\\d{1,9})?\");\n}","tryCatchPattern":"try {\n  iv = CalendarInterval.fromDayTimeString(s);\n} catch (IllegalArgumentException e) {\n  log.warn(\"Skipping malformed day-time interval '{}'\", s);\n  iv = CalendarInterval.ZERO;\n}","preventionTips":["Format literals strictly as 'd h:m:s.n'","Limit fractional seconds to 9 digits","Convert dialect-specific syntax (e.g. '1 day') before parsing"],"tags":["java","parsing","interval","illegal-argument"],"backgroundTag":"invalid-argument-format","analyzedSha":"65f8d8beb752f935752f2a0eec0ab017facab9ef","analyzedAt":"2026-09-11T00:12:21.696Z","contentChangedAt":"2026-09-11T00:12:21.696Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}