{"record":{"id":"a099147ebc4fce5f","repo":"languagetool-org/languagetool","slug":"expected-date-in-format-dd-mm-yyyy-datestr","errorCode":null,"errorMessage":"Expected date in format 'dd-mm-yyyy': '\" + dateString + \"'","messagePattern":"Expected date in format 'dd-mm-yyyy': '\" \\+ dateString \\+ \"'","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"languagetool-language-modules/fr/src/main/java/org/languagetool/rules/fr/DMYDateCheckFilter.java","lineNumber":41,"sourceCode":"\nimport java.util.List;\nimport java.util.Map;\n\n/**\n * Date filter that expects a 'date' argument in the format 'dd-mm-yyyy'.\n * @since 2.7\n */\npublic class DMYDateCheckFilter extends DateCheckFilter {\n\n  @Override\n  public RuleMatch acceptRuleMatch(RuleMatch match, Map<String, String> args, int patternTokenPos, AnalyzedTokenReadings[] patternTokens, List<Integer> tokenPositions) {\n    if (args.containsKey(\"year\") || args.containsKey(\"month\") || args.containsKey(\"day\")) {\n      throw new RuntimeException(\"Set only 'weekDay' and 'date' for \" + DMYDateCheckFilter.class.getSimpleName());\n    }\n    String dateString = getRequired(\"date\", args);\n    String[] parts = dateString.split(\"-\");\n    if (parts.length != 3) {\n      throw new RuntimeException(\"Expected date in format 'dd-mm-yyyy': '\" + dateString + \"'\");\n    }\n    args.put(\"day\", parts[0]);\n    args.put(\"month\", parts[1]);\n    args.put(\"year\", parts[2]);\n    return super.acceptRuleMatch(match, args, patternTokenPos, patternTokens, tokenPositions);\n  }\n\n}\n","sourceCodeStart":23,"sourceCodeEnd":50,"githubUrl":"https://github.com/languagetool-org/languagetool/blob/2e990059ce67d5e2a0f7f7ca5d31160c6709df4b/languagetool-language-modules/fr/src/main/java/org/languagetool/rules/fr/DMYDateCheckFilter.java#L23-L50","documentation":"After fetching the required 'date' argument, DMYDateCheckFilter splits it on '-' and expects exactly three parts (dd-mm-yyyy). This RuntimeException is thrown when the date string does not have exactly three dash-separated parts, so the filter cannot populate day/month/year for the parent DateCheckFilter.","triggerScenarios":"acceptRuleMatch receives a rule whose 'date' filter argument is missing dashes (e.g. '25.12.2024', '25122024'), has extra dashes, is empty, or is a placeholder like 'dd-mm-yyyy' — anything where dateString.split(\"-\").length != 3.","commonSituations":"Rule authors write dates in their locale's notation (dots, slashes, yyyy-mm-dd), leave the attribute empty or with a placeholder value, or a regex in the pattern captured a different date format than the filter expects.","solutions":["Set the 'date' argument to a dd-mm-yyyy string, e.g. 'date:07-09-2026'.","If the pattern emits another format, reorder/normalize the captured groups before the filter runs or adjust the rule regex.","Ensure the XML attribute actually contains a value (no empty args=\"date:\")."],"exampleFix":"<!-- before -->\n<filter class=\"org.languagetool.rules.fr.DMYDateCheckFilter\" args=\"date:2026-09-07\"/>\n<!-- after -->\n<filter class=\"org.languagetool.rules.fr.DMYDateCheckFilter\" args=\"date:07-09-2026\"/>","handlingStrategy":"validation","validationCode":"String date = args.get(\"date\");\nif (date == null || !date.matches(\"\\\\d{1,2}-\\\\d{1,2}-\\\\d{4}\")) {\n    throw new IllegalArgumentException(\"'date' must be dd-mm-yyyy: \" + date);\n}","typeGuard":null,"tryCatchPattern":"try { filter.acceptRuleMatch(match, args, pos, tokens, tp); } catch (RuntimeException e) { LOG.warn(\"Invalid 'date' arg: \" + e.getMessage()); }","preventionTips":["Always write dates as dd-mm-yyyy in French date filter args.","Validate date args when authoring rules with a small unit test.","Normalize captured groups if the pattern emits another format."],"tags":["java","languagetool","date-format","french"],"backgroundTag":"invalid-date-format","analyzedSha":"2e990059ce67d5e2a0f7f7ca5d31160c6709df4b","analyzedAt":"2026-09-06T09:20:17.015Z","contentChangedAt":"2026-09-06T09:20:17.015Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}