languagetool-org/languagetool · error

Could not find month '<monthStr>'

Error message

Could not find month '<monthStr>'

What it means

The Dutch DateCheckFilter's getMonth maps Dutch month names/abbreviations (jan…dec, including okt/oct) to month numbers and throws this RuntimeException when no prefix matches. It indicates the rule fed an unrecognized month token into the filter.

Source

Thrown at languagetool-language-modules/nl/src/main/java/org/languagetool/rules/nl/DateCheckFilter.java:84

  @SuppressWarnings({"ControlFlowStatementWithoutBraces", "MagicNumber"})
  @Override
  protected int getMonth(String monthStr) {
    String mon = monthStr.toLowerCase();
    if (mon.startsWith("jan")) return 1;
    if (mon.startsWith("feb")) return 2;
    if (mon.startsWith("maa")) return 3;
    if (mon.startsWith("mrt")) return 3;
    if (mon.startsWith("mar")) return 3;
    if (mon.startsWith("apr")) return 4;
    if (mon.startsWith("mei")) return 5;
    if (mon.startsWith("jun")) return 6;
    if (mon.startsWith("jul")) return 7;
    if (mon.startsWith("aug")) return 8;
    if (mon.startsWith("sep")) return 9;
    if (mon.startsWith("okt") || mon.startsWith("oct")) return 10;
    if (mon.startsWith("nov")) return 11;
    if (mon.startsWith("dec")) return 12;
    throw new RuntimeException("Could not find month '" + monthStr + "'");
  }

  @Override
  protected String getErrorMessageWrongYear() {
    return "Deze datum is onjuist. Bedoelt u misschien \"{currentYear}\"?";
  }
}

View on GitHub (pinned to 2e990059ce)

Solutions

  1. Add a mapping for the unrecognized prefix shown in the message
  2. Lowercase/normalize the token before the checks
  3. Keep the rule's regex alternation synchronized with the prefixes handled in getMonth

Example fix

// before
if (mon.startsWith("dec")) return 12;
throw new RuntimeException("Could not find month '" + monthStr + "'");
// after
String m = monthStr.toLowerCase();
if (m.startsWith("dec")) return 12;
throw new RuntimeException("Could not find month '" + monthStr + "'");
Defensive patterns

Strategy: validation

Validate before calling

if (monthStr == null || monthStr.isBlank() || !monthStr.toLowerCase().matches("(jan|feb|mrt|maa|apr|mei|jun|jul|aug|sep|okt|oct|nov|dec).*")) throw new IllegalArgumentException("Unrecognized Dutch month: " + monthStr);

Type guard

boolean isDutchMonth(String s) { String m = s == null ? "" : s.toLowerCase(); return m.startsWith("jan")||m.startsWith("feb")||m.startsWith("mrt")||m.startsWith("maa")||m.startsWith("apr")||m.startsWith("mei")||m.startsWith("jun")||m.startsWith("jul")||m.startsWith("aug")||m.startsWith("sep")||m.startsWith("okt")||m.startsWith("oct")||m.startsWith("nov")||m.startsWith("dec"); }

Try / catch

try { month = filter.getMonth(monthStr); } catch (RuntimeException e) { log.warn("Dutch month not recognized: {}", monthStr); return null; }

Prevention

When it happens

Trigger: A rule passes a month string not starting with jan/feb/mrt|maa/apr/mei/jun/jul/aug/sep/okt/oct/nov/dec (e.g. English 'march', a Roman numeral, or unexpected abbreviation).

Common situations: Adding new month abbreviations to a rule regex without extending getMonth; mixed-case input failing startsWith checks; language mixing where an English/German month token is matched.

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


AI-assisted analysis of languagetool-org/languagetool@2e990059ce (2026-09-06). Data as JSON: /api/errors/e1ed7fadfe4150ce. Report an issue: GitHub.