{"record":{"id":"af5a959b1a03d730","repo":"MyCATApache/Mycat-Server","slug":"error-parsing-interval-day-time-string","errorCode":null,"errorMessage":"Error parsing interval day-time string: ","messagePattern":"Error parsing interval day-time string: ","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"src/main/java/io/mycat/memory/unsafe/types/CalendarInterval.java","lineNumber":160,"sourceCode":"    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    }\n    return result;\n  }\n\n  public static CalendarInterval fromSingleUnitString(String unit, String s)\n      throws IllegalArgumentException {\n\n    CalendarInterval result = null;\n    if (s == null) {\n      throw new IllegalArgumentException(String.format(\"Interval %s string was null\", unit));\n    }\n    s = s.trim();\n    Matcher m = quoteTrimPattern.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);","sourceCodeStart":142,"sourceCodeEnd":178,"githubUrl":"https://github.com/MyCATApache/Mycat-Server/blob/65f8d8beb752f935752f2a0eec0ab017facab9ef/src/main/java/io/mycat/memory/unsafe/types/CalendarInterval.java#L142-L178","documentation":"After regex matching, fromDayTimeString converts day/hour/minute/second/nanosecond groups with toLongWithRange (hours 0-23, minutes 0-59, seconds 0-59, nanos 0-999999999) and checks overflow of the microsecond total. Any exception is rethrown as this IllegalArgumentException with the original cause.","triggerScenarios":"Calling fromDayTimeString with a format-matching string containing out-of-range parts, e.g. \"1 25:00:00.0\" (hour 25), \"1 12:75:00.0\" (minute 75), or \"1 12:00:00.1234567890\" (nano overflow).","commonSituations":"Durations computed by external tools that do not normalize time units, hand-edited literals with hour values >= 24, more than 9 digits of fractional seconds.","solutions":["Normalize each field into range (hours 0-23, minutes 0-59, seconds 0-59)","Carry excess units into days (e.g. '1 25:00:00.0' -> '2 01:00:00.0')","Limit fractional seconds to 9 digits"],"exampleFix":"// before\nCalendarInterval iv = CalendarInterval.fromDayTimeString(\"1 25:30:00.0\");\n// after\nCalendarInterval iv = CalendarInterval.fromDayTimeString(\"2 01:30:00.0\");","handlingStrategy":"validation","validationCode":"static void requireDayTimeRanges(String s) {\n  String[] p = s.trim().replaceFirst(\"^-\", \"\").split(\"[ :.]\");\n  if (Long.parseLong(p[1]) > 23 || Long.parseLong(p[2]) > 59 || Long.parseLong(p[3]) > 59)\n    throw new IllegalArgumentException(\"hour/min/sec out of range\");\n  if (p.length > 4 && p[4].length() > 9)\n    throw new IllegalArgumentException(\"nanoseconds exceed 9 digits\");\n}","typeGuard":null,"tryCatchPattern":"try {\n  iv = CalendarInterval.fromDayTimeString(s);\n} catch (IllegalArgumentException e) {\n  throw new IllegalArgumentException(\"Invalid day-time interval \" + s, e.getCause());\n}","preventionTips":["Normalize hours >= 24 into days before parsing","Keep minutes/seconds within 0-59","Truncate fractional seconds to 9 digits"],"tags":["java","parsing","interval","range"],"backgroundTag":"value-out-of-range","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"}