{"record":{"id":"7b5c931fae244cf5","repo":"MyCATApache/Mycat-Server","slug":"columnvalue-columnvalue-please-check-if-the-form-7b5c93","errorCode":null,"errorMessage":"columnValue:{columnValue} Please check if the format satisfied.","messagePattern":"columnValue:(.+?) Please check if the format satisfied\\.","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"src/main/java/io/mycat/route/function/PartitionByRangeDateHash.java","lineNumber":81,"sourceCode":"        {\n            throw new IllegalArgumentException(e);\n        }\n        partionTime = Integer.parseInt(sPartionDay) * oneDay;\n    }\n\n    @Override\n    public Integer calculate(String columnValue)  {\n        try\n        {\n            long targetTime = formatter.get().parse(\n                    columnValue).getTime();\n            int targetPartition = (int) ((targetTime - beginDate) / partionTime);\n            int innerIndex =  Hashing.consistentHash(targetTime,intGroupPartionSize);\n            return targetPartition * intGroupPartionSize + innerIndex;\n\n        } catch (ParseException e)\n        {\n            throw new IllegalArgumentException(new StringBuilder().append(\"columnValue:\").append(columnValue).append(\" Please check if the format satisfied.\").toString(),e);\n        }\n    }\n\n    public Integer calculateStart(String columnValue)\n    {\n        try\n        {\n            long targetTime = formatter.get().parse(columnValue).getTime();\n            int targetPartition = (int) ((targetTime - beginDate) / partionTime);\n            return targetPartition * intGroupPartionSize;\n\n        } catch (ParseException e)\n        {\n            throw new IllegalArgumentException(e);\n\n        }\n    }\n","sourceCodeStart":63,"sourceCodeEnd":99,"githubUrl":"https://github.com/MyCATApache/Mycat-Server/blob/65f8d8beb752f935752f2a0eec0ab017facab9ef/src/main/java/io/mycat/route/function/PartitionByRangeDateHash.java#L63-L99","documentation":"PartitionByRangeDateHash.calculate() parses the column value as a date using an internal SimpleDateFormat with the configured dateFormat. Any ParseException (unparseable or wrong-format date string) is rethrown as this IllegalArgumentException. The value must match the rule's dateFormat exactly to be routed.","triggerScenarios":"Calling calculate(columnValue) with a date string not matching the configured dateFormat, e.g. passing \"2023/01/15\" when dateFormat=yyyy-MM-dd, passing \"2023-1-5\" (non-padded), or passing a datetime string when only a date format is configured.","commonSituations":"Column stores dates in a different format than the rule's <property name=\"dateFormat\">; applications write ISO-8601 with time and timezone but the rule expects plain dates; data migrated from another system with a legacy format; null or empty values submitted for the sharding column.","solutions":["Align the rule's dateFormat property with the actual stored date format, or normalize the column values.","Normalize/parse the date in the application before routing so it matches the expected pattern exactly (including zero-padding).","Pre-validate the sharding column with a SimpleDateFormat of the configured pattern and reject bad rows before reaching the router.","If multiple formats must be supported, wrap calculate() with a fallback parser that converts to the canonical format."],"exampleFix":"// before (dateFormat=yyyy-MM-dd)\ncalculate(\"2023/01/15\"); // IllegalArgumentException\n// after\nString v = \"2023/01/15\";\nDate d = new SimpleDateFormat(\"yyyy/MM/dd\").parse(v);\nString v2 = new SimpleDateFormat(\"yyyy-MM-dd\").format(d);\ncalculate(v2); // routes normally","handlingStrategy":"validation","validationCode":"SimpleDateFormat check = new SimpleDateFormat(\"yyyy-MM-dd\"); // same as rule dateFormat\ncheck.setLenient(false);\ntry { check.parse(columnValue); } catch (ParseException e) { throw new IllegalArgumentException(\"bad date for sharding: \" + columnValue); }","typeGuard":"boolean matchesDateFormat(String v, String pattern) {\n  SimpleDateFormat sdf = new SimpleDateFormat(pattern);\n  sdf.setLenient(false);\n  try { sdf.parse(v); return true; } catch (ParseException e) { return false; }\n}","tryCatchPattern":"try { idx = rule.calculate(value); } catch (IllegalArgumentException e) { /* normalize the date to the rule's dateFormat and retry, else reject */ }","preventionTips":["Make the rule's dateFormat exactly match the stored column format, including zero-padding.","Normalize dates at write time so the sharding column always holds the canonical format.","Set lenient=false when pre-validating to catch malformed dates early."],"tags":["date-format","sharding","input-validation"],"backgroundTag":"invalid-date-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"}