languagetool-org/languagetool · error · RuntimeException
Could not find day of week for '<dayStr>'
Error message
Could not find day of week for '<dayStr>'
What it means
DateCheckFilter for Ukrainian maps a day-of-week token (Ukrainian weekday names or two-letter abbreviations) to a java.util.Calendar constant. If the token matches none of the recognized prefixes or abbreviations, getDayOfWeek throws this RuntimeException indicating an unrecognized Ukrainian weekday string.
Source
Thrown at languagetool-language-modules/uk/src/main/java/org/languagetool/rules/uk/DateCheckFilter.java:47
*/
public class DateCheckFilter extends AbstractDateCheckFilter {
@Override
protected Calendar getCalendar() {
return Calendar.getInstance(Locale.forLanguageTag("uk"));
}
@Override
protected int getDayOfWeek(String dayStr) {
String day = dayStr.toLowerCase();
if (day.startsWith("по") || day.equals("пн")) return Calendar.MONDAY;
if (day.startsWith("ві") || day.equals("вт")) return Calendar.TUESDAY;
if (day.startsWith("се") || day.equals("ср")) return Calendar.WEDNESDAY;
if (day.startsWith("че") || day.equals("чт")) return Calendar.THURSDAY;
if (day.startsWith("п'") || day.startsWith("п’") || day.equals("пт")) return Calendar.FRIDAY;
if (day.startsWith("су") || day.equals("сб")) return Calendar.SATURDAY;
if (day.startsWith("не") || day.equals("нд")) 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("uk"));
}
@Override
protected int getMonth(String monthStr) {
String mon = monthStr.toLowerCase();
if (mon.startsWith("сі")) return Calendar.JANUARY + 1;
if (mon.startsWith("лю")) return Calendar.FEBRUARY + 1;
if (mon.startsWith("бе")) return Calendar.MARCH + 1;
if (mon.startsWith("кв")) return Calendar.APRIL + 1;
if (mon.startsWith("тр")) return Calendar.MAY + 1;
if (mon.startsWith("че")) return Calendar.JUNE + 1;
if (mon.startsWith("ли")) return Calendar.JULY + 1;
if (mon.startsWith("се")) return Calendar.AUGUST + 1;View on GitHub (pinned to 2e990059ce)
Solutions
- Check the exact day string — it must start with по/ві/се/че/п'/п’/су/не or equal an accepted abbreviation.
- Normalize case, trim, and normalize apostrophes (straight ' vs typographic ’) before the filter runs.
- Extend the checks in DateCheckFilter.getDayOfWeek if additional inflected/abbreviated forms must be supported.
- Constrain the rule regex so only nominative weekday forms reach the filter.
Example fix
// before: unhandled unmatched form
throw new RuntimeException("Could not find day of week for '" + dayStr + "'");
// after: pre-validate in caller with apostrophe normalization
String day = dayStr.trim().toLowerCase(Locale.forLanguageTag("uk")).replace('\'', '’');
List<String> prefixes = List.of("по","ві","се","че","п’","су","не");
if (prefixes.stream().noneMatch(day::startsWith)) {
throw new IllegalArgumentException("Unrecognized Ukrainian day of week: " + dayStr);
} Defensive patterns
Strategy: validation
Validate before calling
private static final List<String> UK_DAY_PREFIXES = List.of("по","ві","се","че","п’","су","не");
boolean isRecognizedUkrainianDay(String dayStr) {
String d = dayStr == null ? "" : dayStr.trim().toLowerCase(Locale.forLanguageTag("uk")).replace('\'', '’');
return UK_DAY_PREFIXES.stream().anyMatch(d::startsWith);
} Try / catch
try {
int dayOfWeek = filter.getDayOfWeek(dayStr);
} catch (RuntimeException e) {
logger.warn("Unrecognized Ukrainian day token: {}", dayStr);
// skip the date suggestion
} Prevention
- Normalize apostrophes: straight (') vs typographic (’) both occur in Ukrainian text.
- Reject Russian-style abbreviations (пн, вт, сб, нд subset) before reaching the filter.
- Cover all inflected weekday forms your grammar rules can capture in tests.
When it happens
Trigger: Passing a day string like 'mon', 'нд' misspelled, an inflected form ('у понеділок'), or an abbreviation not in the accepted list ('вс' for неділя) into getDayOfWeek via a date-matching rule.
Common situations: Grammar rules that capture weekday names inside prepositional phrases (which inflect the noun); Russian-style abbreviations ('пн','вт') leaking into Ukrainian text; custom rule typos.
Related errors
- Could not find month '<monthStr>'
- 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/94c009b9f2a80799.
Report an issue: GitHub.