languagetool-org/languagetool · error
Could not find day of week for '<dayStr>'
Error message
Could not find day of week for '<dayStr>'
What it means
The Dutch DateCheckFilter maps Dutch weekday tokens (abbreviations ma/di/wo/do/vr/za and full names maandag…zaterdag) to Calendar constants. It throws this RuntimeException when the day string matches none of them. Notably there is no Sunday ('zo'/'zondag') branch, so any Sunday token reaching this method throws.
Source
Thrown at languagetool-language-modules/nl/src/main/java/org/languagetool/rules/nl/DateCheckFilter.java:49
@Override
protected Calendar getCalendar() {
return Calendar.getInstance(Locale.UK);
}
@SuppressWarnings("ControlFlowStatementWithoutBraces")
@Override
protected int getDayOfWeek(String dayStr) {
String day = dayStr.toLowerCase();
if (day.equals("zo") || day.equals("zondag")) return Calendar.SUNDAY;
if (day.equals("ma") || day.equals("maandag")) return Calendar.MONDAY;
if (day.equals("di") || day.equals("dinsdag")) return Calendar.TUESDAY;
if (day.equals("wo") || day.equals("woensdag")) return Calendar.WEDNESDAY;
if (day.equals("do") || day.equals("donderdag")) return Calendar.THURSDAY;
if (day.equals("vr") || day.equals("vrijdag")) return Calendar.FRIDAY;
if (day.equals("za") || day.equals("zaterdag")) return Calendar.SATURDAY;
throw new RuntimeException("Could not find day of week for '" + dayStr + "'");
}
@SuppressWarnings("ControlFlowStatementWithoutBraces")
@Override
protected String getDayOfWeek(Calendar date) {
String englishDay = date.getDisplayName(Calendar.DAY_OF_WEEK, Calendar.LONG, Locale.UK);
if (englishDay.equals("Sunday")) return "zondag";
if (englishDay.equals("Monday")) return "maandag";
if (englishDay.equals("Tuesday")) return "dinsdag";
if (englishDay.equals("Wednesday")) return "woensdag";
if (englishDay.equals("Thursday")) return "donderdag";
if (englishDay.equals("Friday")) return "vrijdag";
if (englishDay.equals("Saturday")) return "zaterdag";
return "";
}
@SuppressWarnings({"ControlFlowStatementWithoutBraces", "MagicNumber"})
@OverrideView on GitHub (pinned to 2e990059ce)
Solutions
- Add Sunday mapping: if (day.equals("zo") || day.equals("zondag")) return Calendar.SUNDAY;
- Check the message's day string and make sure the caller passes the lowercased, trimmed token
- Update the rule regex so it only emits tokens covered by the mapping
Example fix
// before
if (day.equals("za") || day.equals("zaterdag")) return Calendar.SATURDAY;
throw new RuntimeException("Could not find day of week for '" + dayStr + "'");
// after
if (day.equals("za") || day.equals("zaterdag")) return Calendar.SATURDAY;
if (day.equals("zo") || day.equals("zondag")) return Calendar.SUNDAY;
throw new RuntimeException("Could not find day of week for '" + dayStr + "'"); Defensive patterns
Strategy: validation
Validate before calling
Set<String> known = Set.of("ma","di","wo","do","vr","za","maandag","dinsdag","woensdag","donderdag","vrijdag","zaterdag");
if (!known.contains(dayStr.toLowerCase())) throw new IllegalArgumentException("Unrecognized Dutch weekday: " + dayStr); Type guard
boolean isDutchWeekday(String s) { String d = s == null ? "" : s.toLowerCase(); return Set.of("ma","di","wo","do","vr","za","maandag","dinsdag","woensdag","donderdag","vrijdag","zaterdag").contains(d); } Try / catch
try { day = filter.getDayOfWeek(dayStr); } catch (RuntimeException e) { log.debug("Skipping unmatched Dutch weekday {}", dayStr); } Prevention
- Add Sunday ('zo'/'zondag') to tests — it is missing today
- Remember exact equals() matching: pass exact lowercase full names or the two-letter abbreviations only
- Keep rule regex and mapping synchronized with a unit test
When it happens
Trigger: A Dutch date rule matches 'zondag' or 'zo' and calls getDayOfWeek, which has no Sunday mapping; or the token differs from the exact equals() strings (case differences, extra characters).
Common situations: Dates in text containing Sunday matched by the rule; weekday abbreviations in different case since the filter uses exact equals, not startsWith.
Understand the failure class
Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.
Related errors
- Could not find day of week for '<dayStr>'
- Could not find month '<monthStr>'
- Could not find month '<monthStr>'
- Could not find day of week for '<dayStr>'
- Could not find month '<monthStr>'
AI-assisted analysis of languagetool-org/languagetool@2e990059ce (2026-09-06).
Data as JSON: /api/errors/5ec3b516327c1422.
Report an issue: GitHub.