stanfordnlp/CoreNLP · error · IllegalArgumentException

Unsupported formatter

Error message

Unsupported formatter: ${formatter}

What it means

Thrown when a SUTime extraction rule declares a formatter value that TimeFormatter.create does not recognize. Only "org.joda.time.format.ISODateTimeFormat" and "java.text.SimpleDateFormat" are supported; anything else is rejected at rule-construction time.

Solutions

  1. Set formatter to exactly "org.joda.time.format.ISODateTimeFormat" or "java.text.SimpleDateFormat".
  2. If you need java.time patterns, express them as a java.text.SimpleDateFormat pattern in the rule.
  3. Remove the formatter field entirely to use the default parsing path.

Example fix

// before
{ formatter: "java.time.format.DateTimeFormatter", expr: "yyyy-MM-dd" }
// after
{ formatter: "java.text.SimpleDateFormat", expr: "yyyy-MM-dd" }
Defensive patterns

Strategy: validation

Validate before calling

java.util.Set<String> SUPPORTED = new java.util.HashSet<>(
  java.util.Arrays.asList("org.joda.time.format.ISODateTimeFormat", "java.text.SimpleDateFormat"));
if (formatter != null && !SUPPORTED.contains(formatter))
  throw new IllegalArgumentException("Rule uses unsupported formatter: " + formatter);

Try / catch

try {
  loadRules(ruleFile);
} catch (IllegalArgumentException e) {
  if (e.getMessage() != null && e.getMessage().startsWith("Unsupported formatter:")) {
    log.error("Fix formatter field in " + ruleFile + ": " + e.getMessage());
  } else throw e;
}

Prevention

When it happens

Trigger: A .sutime.txt rule containing formatter: "DateTimeFormatter" or any other unrecognized class name, e.g. formatter: "java.time.format.DateTimeFormatter" (java.time is not supported).

Common situations: Porting rules to newer Java and assuming java.time formatters are supported; typos in the formatter string; rules copied from other libraries.

Related errors


AI-assisted analysis of stanfordnlp/CoreNLP@1b7edd19c4 (2026-09-10). Data as JSON: /api/errors/c68178822919a99a. Report an issue: GitHub.

Appendix: source

Thrown at src/edu/stanford/nlp/time/TimeFormatter.java:171

        //SequenceMatchRules.Expression result = (SequenceMatchRules.Expression) attributes.get("result");
        updateExtractRule(r, env, formatExtractor.getTextPattern(), new ApplyActionWrapper<>(env, formatExtractor, action));
      } else if ("org.joda.time.format.DateTimeFormat".equals(formatter)) {
        if (r.annotationField == null) { r.annotationField = r.tokensAnnotationField;  }
        updateExtractRule(r, env, new ApplyActionWrapper<>(env, new JodaDateTimeFormatExtractor(expr), action));
      } else if ("org.joda.time.format.ISODateTimeFormat".equals(formatter)) {
        if (r.annotationField == null) { r.annotationField = r.tokensAnnotationField;  }
        try {
          Method m = ISODateTimeFormat.class.getMethod(expr);
          DateTimeFormatter dtf = (DateTimeFormatter) m.invoke(null);
          updateExtractRule(r, env, new ApplyActionWrapper<>(env, new JodaDateTimeFormatExtractor(expr), action));
        } catch (Exception ex) {
          throw new RuntimeException("Error creating DateTimeFormatter", ex);
        }
      } else if ("java.text.SimpleDateFormat".equals(formatter)) {
        if (r.annotationField == null) { r.annotationField = r.tokensAnnotationField;  }
        updateExtractRule(r, env, new ApplyActionWrapper<>(env, new JavaDateFormatExtractor(expr), action));
      } else {
        throw new IllegalArgumentException("Unsupported formatter: " + formatter);
      }
      return r;
    }
  }

  /*
   * Rules for parsing time specific patterns.
   * Patterns are similar to time patterns used by JodaTime combined with a simplified regex expression
   *
   # y       year                         year          1996                         y
   # M       month of year                month         July; Jul; 07                M
   # d       day of month                 number        10                           d
   # H       hour of day (0~23)           number        0                            H
   # k       clockhour of day (1~24)      number        24                           k
   # m       minute of hour               number        30                           m
   # s       second of minute             number        55                           s
   # S       fraction of second           number        978                          S (Millisecond)
   # a       half day of day marker       am/pm

View on GitHub (pinned to 1b7edd19c4)