{"record":{"id":"4abb246875acc232","repo":"MyCATApache/Mycat-Server","slug":"interval-string-does-not-match-second-nano-format","errorCode":null,"errorMessage":"Interval string does not match second-nano format of ss.nnnnnnnnn","messagePattern":"Interval string does not match second-nano format of ss\\.nnnnnnnnn","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"src/main/java/io/mycat/memory/unsafe/types/CalendarInterval.java","lineNumber":247,"sourceCode":"  }\n\n  /**\n   * Parse second_nano string in ss.nnnnnnnnn format to microseconds\n   */\n  public static long parseSecondNano(String secondNano) throws IllegalArgumentException {\n    String[] parts = secondNano.split(\"\\\\.\");\n    if (parts.length == 1) {\n      return toLongWithRange(\"second\", parts[0], Long.MIN_VALUE / MICROS_PER_SECOND,\n        Long.MAX_VALUE / MICROS_PER_SECOND) * MICROS_PER_SECOND;\n\n    } else if (parts.length == 2) {\n      long seconds = parts[0].equals(\"\") ? 0L : toLongWithRange(\"second\", parts[0],\n        Long.MIN_VALUE / MICROS_PER_SECOND, Long.MAX_VALUE / MICROS_PER_SECOND);\n      long nanos = toLongWithRange(\"nanosecond\", parts[1], 0L, 999999999L);\n      return seconds * MICROS_PER_SECOND + nanos / 1000L;\n\n    } else {\n      throw new IllegalArgumentException(\n        \"Interval string does not match second-nano format of ss.nnnnnnnnn\");\n    }\n  }\n\n  public final int months;\n  public final long microseconds;\n\n  public CalendarInterval(int months, long microseconds) {\n    this.months = months;\n    this.microseconds = microseconds;\n  }\n\n  public CalendarInterval add(CalendarInterval that) {\n    int months = this.months + that.months;\n    long microseconds = this.microseconds + that.microseconds;\n    return new CalendarInterval(months, microseconds);\n  }\n","sourceCodeStart":229,"sourceCodeEnd":265,"githubUrl":"https://github.com/MyCATApache/Mycat-Server/blob/65f8d8beb752f935752f2a0eec0ab017facab9ef/src/main/java/io/mycat/memory/unsafe/types/CalendarInterval.java#L229-L265","documentation":"parseSecondNano parses a seconds-with-fraction string like '12.999999999' and throws this IllegalArgumentException when the input does not split into exactly two parts around the decimal point with non-empty valid components — i.e. it is not in ss.nnnnnnnnn form.","triggerScenarios":"Calling CalendarInterval.parseSecondNano(\"12\"), parseSecondNano(\"1.2.3\"), parseSecondNano(\"abc.def\"), or parseSecondNano(\"\") — e.g. from the micros() accessor with a malformed seconds string.","commonSituations":"Truncated fractional seconds from string splitting, locale decimal commas ('12,5'), missing nano part after the dot.","solutions":["Ensure the string has exactly one '.' separating integer seconds and nanoseconds, e.g. '12.5' not '12' or '12.5.6'","Convert locale decimal commas to '.' before parsing","Validate with a regex like ^\\d*\\.\\d*$ before calling"],"exampleFix":"// before\nlong micros = interval.parseSecondNano(\"12,5\");\n// after\nlong micros = interval.parseSecondNano(\"12.500000000\");","handlingStrategy":"validation","validationCode":"private static final Pattern SS_N = Pattern.compile(\"^\\\\d*\\\\.\\\\d{1,9}$\");\nstatic void requireSecondNano(String s) {\n  if (s == null || !SS_N.matcher(s).matches())\n    throw new IllegalArgumentException(\"expected ss.nnnnnnnnn, got: \" + s);\n}","typeGuard":"static boolean isSecondNano(String s) {\n  return s != null && s.matches(\"\\\\d*\\\\.\\\\d{1,9}\");\n}","tryCatchPattern":"try {\n  long micros = parseSecondNano(s);\n} catch (IllegalArgumentException e) {\n  log.warn(\"Malformed seconds.nanos '{}'\", s);\n  micros = 0L;\n}","preventionTips":["Ensure exactly one '.' with digits on both sides","Replace locale decimal commas with '.' first","Pad the fractional part when fixed width is required"],"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"}