languagetool-org/languagetool · error · RuntimeException
Expected date in format 'dd-mm-yyyy': '" + dateString + "'
Error message
Expected date in format 'dd-mm-yyyy': '" + dateString + "'
What it means
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.
Source
Thrown at languagetool-language-modules/fr/src/main/java/org/languagetool/rules/fr/DMYDateCheckFilter.java:41
import java.util.List;
import java.util.Map;
/**
* Date filter that expects a 'date' argument in the format 'dd-mm-yyyy'.
* @since 2.7
*/
public class DMYDateCheckFilter extends DateCheckFilter {
@Override
public RuleMatch acceptRuleMatch(RuleMatch match, Map<String, String> args, int patternTokenPos, AnalyzedTokenReadings[] patternTokens, List<Integer> tokenPositions) {
if (args.containsKey("year") || args.containsKey("month") || args.containsKey("day")) {
throw new RuntimeException("Set only 'weekDay' and 'date' for " + DMYDateCheckFilter.class.getSimpleName());
}
String dateString = getRequired("date", args);
String[] parts = dateString.split("-");
if (parts.length != 3) {
throw new RuntimeException("Expected date in format 'dd-mm-yyyy': '" + dateString + "'");
}
args.put("day", parts[0]);
args.put("month", parts[1]);
args.put("year", parts[2]);
return super.acceptRuleMatch(match, args, patternTokenPos, patternTokens, tokenPositions);
}
}
View on GitHub (pinned to 2e990059ce)
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:").
Example fix
<!-- before --> <filter class="org.languagetool.rules.fr.DMYDateCheckFilter" args="date:2026-09-07"/> <!-- after --> <filter class="org.languagetool.rules.fr.DMYDateCheckFilter" args="date:07-09-2026"/>
Defensive patterns
Strategy: validation
Validate before calling
String date = args.get("date");
if (date == null || !date.matches("\\d{1,2}-\\d{1,2}-\\d{4}")) {
throw new IllegalArgumentException("'date' must be dd-mm-yyyy: " + date);
} Try / catch
try { filter.acceptRuleMatch(match, args, pos, tokens, tp); } catch (RuntimeException e) { LOG.warn("Invalid 'date' arg: " + e.getMessage()); } Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- Expected date in format 'yyyy-mm-dd': '" + dateString + "'
- Set only 'weekDay' and 'date' for " + DMYDateCheckFilter.cla
- Could not find day of week for '" + dayStr + "'
- Could not find month '" + monthStr + "'
- Could not tag and disambiguate '" + token + "'
AI-assisted analysis of languagetool-org/languagetool@2e990059ce (2026-09-06).
Data as JSON: /api/errors/a099147ebc4fce5f.
Report an issue: GitHub.