{"record":{"id":"ef9a6b7da2db3edf","repo":"languagetool-org/languagetool","slug":"monthstr","errorCode":null,"errorMessage":"Месец '<monthStr>' не постоји.","messagePattern":"Месец '<monthStr>' не постоји\\.","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"languagetool-language-modules/sr/src/main/java/org/languagetool/rules/sr/DateCheckFilter.java","lineNumber":73,"sourceCode":"  }\n\n  @SuppressWarnings({\"ControlFlowStatementWithoutBraces\", \"MagicNumber\"})\n  @Override\n  protected int getMonth(String monthStr) {\n    String mon = monthStr.toLowerCase();\n    if (mon.equals(\"јануар\") || monthStr.equals(\"I\") || mon.equals(\"јануара\") || mon.equals(\"јан\")) return 1;\n    if (mon.equals(\"фебруар\") || monthStr.equals(\"II\") || mon.equals(\"фебруара\") || mon.equals(\"феб\")) return 2;\n    if (mon.equals(\"март\") || monthStr.equals(\"III\") || mon.equals(\"марта\") || mon.equals(\"мар\")) return 3;\n    if (mon.equals(\"април\") || monthStr.equals(\"IV\") || mon.equals(\"априла\") || mon.equals(\"апр\")) return 4;\n    if (mon.equals(\"мај\") || monthStr.equals(\"V\") || mon.equals(\"маја\")) return 5;\n    if (mon.equals(\"јун\") || monthStr.equals(\"VI\") || mon.equals(\"јуна\") || mon.equals(\"јун\")) return 6;\n    if (mon.equals(\"јул\") || monthStr.equals(\"VII\") || mon.equals(\"јула\") || mon.equals(\"јул\")) return 7;\n    if (mon.equals(\"август\") || monthStr.equals(\"VIII\") || mon.equals(\"августа\") || mon.equals(\"авг\")) return 8;\n    if (mon.equals(\"септембар\") || monthStr.equals(\"IX\") || mon.equals(\"септембра\") || mon.equals(\"сеп\")) return 9;\n    if (mon.equals(\"октобар\") || monthStr.equals(\"X\") || mon.equals(\"октобра\") || mon.equals(\"окт\")) return 10;\n    if (mon.equals(\"новембар\") || monthStr.equals(\"XI\") || mon.equals(\"новембра\") || mon.equals(\"нов\")) return 11;\n    if (mon.equals(\"децембар\") || monthStr.equals(\"XII\") || mon.equals(\"децембра\") || mon.equals(\"дец\")) return 12;\n    throw new RuntimeException(\"Месец '\" + monthStr + \"' не постоји.\");\n  }\n}\n","sourceCodeStart":55,"sourceCodeEnd":76,"githubUrl":"https://github.com/languagetool-org/languagetool/blob/2e990059ce67d5e2a0f7f7ca5d31160c6709df4b/languagetool-language-modules/sr/src/main/java/org/languagetool/rules/sr/DateCheckFilter.java#L55-L76","documentation":"DateCheckFilter for Serbian maps a month token (Serbian month name/inflected form or Roman numeral like 'VII') to a month number. If the string matches none of the accepted names, abbreviations, or Roman numerals, getMonth throws this RuntimeException indicating an unrecognized month value.","triggerScenarios":"Passing a month string such as 'maj' (Latin for May, not covered), an unrecognized abbreviation, wrong case ('Јул'), a Latin-script form when only Cyrillic entries exist, or an out-of-range Roman numeral into getMonth.","commonSituations":"Rules matching dates written in Latin Serbian script while the filter's month list only covers Cyrillic forms; month names in genitive forms not listed (e.g. 'јула' is listed but others may not cover all inflections); typos in custom grammar rules.","solutions":["Verify the month string is one of the accepted Serbian names/abbreviations or Roman numerals I–XII.","Normalize case and trim whitespace before calling the filter.","If Latin-script dates must be supported, add the missing Latin month forms to getMonth.","Validate the month token in the calling rule before invoking DateCheckFilter."],"exampleFix":"// before: unguarded call\nint month = filter.getMonth(monthStr);\n// after: normalize and pre-validate\nString mon = monthStr.trim().toLowerCase(Locale.forLanguageTag(\"sr\"));\nSet<String> known = Set.of(\"јануар\",\"фебруар\",\"март\",\"април\",\"мај\",\"јун\",\"јул\",\"август\",\"септембар\",\"октобар\",\"новембар\",\"децембар\");\nif (!known.contains(mon) && !mon.matches(\"^(?i)(I|II|III|IV|V|VI|VII|VIII|IX|X|XI|XII)$\")) {\n  throw new IllegalArgumentException(\"Unrecognized month: \" + monthStr);\n}","handlingStrategy":"validation","validationCode":"private static final Set<String> SR_MONTHS = Set.of(\"јануар\",\"фебруар\",\"март\",\"април\",\"мај\",\"јун\",\"јул\",\"август\",\"септембар\",\"октобар\",\"новембар\",\"децембар\");\nboolean isRecognizedSerbianMonth(String monthStr) {\n  String m = monthStr == null ? \"\" : monthStr.trim().toLowerCase(Locale.forLanguageTag(\"sr\"));\n  return SR_MONTHS.contains(m) || m.matches(\"^(?i)(I|II|III|IV|V|VI|VII|VIII|IX|X|XI|XII)$\");\n}","typeGuard":null,"tryCatchPattern":"try {\n  int month = filter.getMonth(monthStr);\n} catch (RuntimeException e) {\n  logger.warn(\"Unrecognized Serbian month token: {}\", monthStr);\n  // reject the date match\n}","preventionTips":["Verify which script (Cyrillic/Latin) your rules emit and that getMonth covers it.","Normalize case and trim whitespace on captured tokens.","Test all 12 months plus the Roman-numeral forms in unit tests."],"tags":["java","serbian","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"}