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 Polish DateCheckFilter maps Polish weekday tokens (pn/pon, wt, śr, czw, pt/piątk…, sob, niedz…) to Calendar constants. getDayOfWeek throws this RuntimeException when the token matches none of these patterns. The Polish mapping requires correctly accented input (śr, piątk), so encoding or deaccenting issues can cause misses.
Source
Thrown at languagetool-language-modules/pl/src/main/java/org/languagetool/rules/pl/DateCheckFilter.java:46
public class DateCheckFilter extends AbstractDateCheckFilter {
@Override
protected Calendar getCalendar() {
return Calendar.getInstance(Locale.forLanguageTag("pl"));
}
@SuppressWarnings("ControlFlowStatementWithoutBraces")
@Override
protected int getDayOfWeek(String dayStr) {
String day = dayStr.toLowerCase();
if (day.startsWith("pon")) return Calendar.MONDAY;
if (day.startsWith("wt")) return Calendar.TUESDAY;
if (day.startsWith("śr")) return Calendar.WEDNESDAY;
if (day.startsWith("czw")) return Calendar.THURSDAY;
if (day.equals("pt") || day.startsWith("piątk") || day.equals("piątek")) return Calendar.FRIDAY;
if (day.startsWith("sob")) return Calendar.SATURDAY;
if (day.startsWith("niedz")) return Calendar.SUNDAY;
throw new RuntimeException("Could not find day of week for '" + dayStr + "'");
}
@Override
protected String getDayOfWeek(Calendar date) {
return date.getDisplayName(Calendar.DAY_OF_WEEK, Calendar.LONG, Locale.forLanguageTag("pl"));
}
@SuppressWarnings({"ControlFlowStatementWithoutBraces", "MagicNumber"})
@Override
protected int getMonth(String monthStr) {
String mon = monthStr.toLowerCase();
if (mon.equals("stycznia") || monthStr.equals("I")) return 1;
if (mon.equals("lutego") || monthStr.equals("II")) return 2;
if (mon.equals("marca") || monthStr.equals("III")) return 3;
if (mon.equals("kwietnia") || monthStr.equals("IV")) return 4;
if (mon.equals("maja") || monthStr.equals("V")) return 5;
if (mon.equals("czerwca") || monthStr.equals("VI")) return 6;
if (mon.equals("lipca") || monthStr.equals("VII")) return 7;View on GitHub (pinned to 2e990059ce)
Solutions
- Add the missing inflected/abbreviated form to the appropriate branch of getDayOfWeek
- Verify input encoding/normalization so 'ś' and 'ą' survive to the filter (UTF-8)
- Align the rule's regex with the exact token forms the mapping recognizes
Example fix
// before
if (day.startsWith("niedz")) return Calendar.SUNDAY;
throw new RuntimeException("Could not find day of week for '" + dayStr + "'");
// after
if (day.startsWith("niedz")) return Calendar.SUNDAY;
if (day.equals("pon") || day.startsWith("poniedzial") || day.startsWith("poniedział")) return Calendar.MONDAY; // add missing forms as needed
throw new RuntimeException("Could not find day of week for '" + dayStr + "'"); Defensive patterns
Strategy: validation
Validate before calling
if (dayStr == null || !dayStr.matches("(?i)(pn|pon.*|wt.*|śr.*|czw.*|pt|piątk.*|piątek|sob.*|niedz.*)")) throw new IllegalArgumentException("Unrecognized Polish weekday: " + dayStr); Type guard
boolean isPolishWeekday(String s) { String d = s == null ? "" : s.toLowerCase(); return d.startsWith("pn")||d.startsWith("wt")||d.startsWith("śr")||d.startsWith("czw")||d.equals("pt")||d.startsWith("piątk")||d.startsWith("sob")||d.startsWith("niedz"); } Try / catch
try { day = filter.getDayOfWeek(dayStr); } catch (RuntimeException e) { log.warn("Polish weekday unmatched: {}", dayStr); /* ignore match */ } Prevention
- Ensure UTF-8 handling end-to-end so 'ś'/'ą' are not mangled to 's'/'a'
- Test inflected weekday forms your regex can produce
- Add every regex alternative to a mapping-coverage test
When it happens
Trigger: A rule matches a weekday token not covered by the patterns (e.g. 'pon' is covered via pn/pon branch — but variants like 'poniedziałek' partial inflections or 'sobota' inflected forms 'soboty' are handled by startsWith; anything else such as an unaccented 'sr' instead of 'śr' throws).
Common situations: Text with ASCII-folded Polish characters ('sr', 'piatek') from other processing steps; rule regex extended with new inflected forms not handled in the mapping.
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 day of week for '<dayStr>'
- 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/68f4185339578442.
Report an issue: GitHub.