{"record":{"id":"94c009b9f2a80799","repo":"languagetool-org/languagetool","slug":"could-not-find-day-of-week-for-daystr-94c009","errorCode":null,"errorMessage":"Could not find day of week for '<dayStr>'","messagePattern":"Could not find day of week for '<dayStr>'","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"languagetool-language-modules/uk/src/main/java/org/languagetool/rules/uk/DateCheckFilter.java","lineNumber":47,"sourceCode":" */\npublic class DateCheckFilter extends AbstractDateCheckFilter {\n\n  @Override\n  protected Calendar getCalendar() {\n    return Calendar.getInstance(Locale.forLanguageTag(\"uk\"));\n  }\n\n  @Override\n  protected int getDayOfWeek(String dayStr) {\n    String day = dayStr.toLowerCase();\n    if (day.startsWith(\"по\") || day.equals(\"пн\")) return Calendar.MONDAY;\n    if (day.startsWith(\"ві\") || day.equals(\"вт\")) return Calendar.TUESDAY;\n    if (day.startsWith(\"се\") || day.equals(\"ср\")) return Calendar.WEDNESDAY;\n    if (day.startsWith(\"че\") || day.equals(\"чт\")) return Calendar.THURSDAY;\n    if (day.startsWith(\"п'\") || day.startsWith(\"п’\") || day.equals(\"пт\")) return Calendar.FRIDAY;\n    if (day.startsWith(\"су\") || day.equals(\"сб\")) return Calendar.SATURDAY;\n    if (day.startsWith(\"не\") || day.equals(\"нд\")) return Calendar.SUNDAY;\n    throw new RuntimeException(\"Could not find day of week for '\" + dayStr + \"'\");\n  }\n\n  @Override\n  protected String getDayOfWeek(Calendar date) {\n    return date.getDisplayName(Calendar.DAY_OF_WEEK, Calendar.LONG, Locale.forLanguageTag(\"uk\"));\n  }\n\n  @Override\n  protected int getMonth(String monthStr) {\n    String mon = monthStr.toLowerCase();\n    if (mon.startsWith(\"сі\")) return Calendar.JANUARY + 1;\n    if (mon.startsWith(\"лю\")) return Calendar.FEBRUARY + 1;\n    if (mon.startsWith(\"бе\")) return Calendar.MARCH + 1;\n    if (mon.startsWith(\"кв\")) return Calendar.APRIL + 1;\n    if (mon.startsWith(\"тр\")) return Calendar.MAY + 1;\n    if (mon.startsWith(\"че\")) return Calendar.JUNE + 1;\n    if (mon.startsWith(\"ли\")) return Calendar.JULY + 1;\n    if (mon.startsWith(\"се\")) return Calendar.AUGUST + 1;","sourceCodeStart":29,"sourceCodeEnd":65,"githubUrl":"https://github.com/languagetool-org/languagetool/blob/2e990059ce67d5e2a0f7f7ca5d31160c6709df4b/languagetool-language-modules/uk/src/main/java/org/languagetool/rules/uk/DateCheckFilter.java#L29-L65","documentation":"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.","triggerScenarios":"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.","commonSituations":"Grammar rules that capture weekday names inside prepositional phrases (which inflect the noun); Russian-style abbreviations ('пн','вт') leaking into Ukrainian text; custom rule typos.","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."],"exampleFix":"// before: unhandled unmatched form\nthrow new RuntimeException(\"Could not find day of week for '\" + dayStr + \"'\");\n// after: pre-validate in caller with apostrophe normalization\nString day = dayStr.trim().toLowerCase(Locale.forLanguageTag(\"uk\")).replace('\\'', '’');\nList<String> prefixes = List.of(\"по\",\"ві\",\"се\",\"че\",\"п’\",\"су\",\"не\");\nif (prefixes.stream().noneMatch(day::startsWith)) {\n  throw new IllegalArgumentException(\"Unrecognized Ukrainian day of week: \" + dayStr);\n}","handlingStrategy":"validation","validationCode":"private static final List<String> UK_DAY_PREFIXES = List.of(\"по\",\"ві\",\"се\",\"че\",\"п’\",\"су\",\"не\");\nboolean isRecognizedUkrainianDay(String dayStr) {\n  String d = dayStr == null ? \"\" : dayStr.trim().toLowerCase(Locale.forLanguageTag(\"uk\")).replace('\\'', '’');\n  return UK_DAY_PREFIXES.stream().anyMatch(d::startsWith);\n}","typeGuard":null,"tryCatchPattern":"try {\n  int dayOfWeek = filter.getDayOfWeek(dayStr);\n} catch (RuntimeException e) {\n  logger.warn(\"Unrecognized Ukrainian day token: {}\", dayStr);\n  // skip the date suggestion\n}","preventionTips":["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."],"tags":["java","ukrainian","date-parsing","languagetool"],"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-14T05:17:10.506Z"}