{"record":{"id":"c68178822919a99a","repo":"stanfordnlp/CoreNLP","slug":"unsupported-formatter-formatter","errorCode":null,"errorMessage":"Unsupported formatter: ${formatter}","messagePattern":"Unsupported formatter: (.+?)","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"src/edu/stanford/nlp/time/TimeFormatter.java","lineNumber":171,"sourceCode":"        //SequenceMatchRules.Expression result = (SequenceMatchRules.Expression) attributes.get(\"result\");\n        updateExtractRule(r, env, formatExtractor.getTextPattern(), new ApplyActionWrapper<>(env, formatExtractor, action));\n      } else if (\"org.joda.time.format.DateTimeFormat\".equals(formatter)) {\n        if (r.annotationField == null) { r.annotationField = r.tokensAnnotationField;  }\n        updateExtractRule(r, env, new ApplyActionWrapper<>(env, new JodaDateTimeFormatExtractor(expr), action));\n      } else if (\"org.joda.time.format.ISODateTimeFormat\".equals(formatter)) {\n        if (r.annotationField == null) { r.annotationField = r.tokensAnnotationField;  }\n        try {\n          Method m = ISODateTimeFormat.class.getMethod(expr);\n          DateTimeFormatter dtf = (DateTimeFormatter) m.invoke(null);\n          updateExtractRule(r, env, new ApplyActionWrapper<>(env, new JodaDateTimeFormatExtractor(expr), action));\n        } catch (Exception ex) {\n          throw new RuntimeException(\"Error creating DateTimeFormatter\", ex);\n        }\n      } else if (\"java.text.SimpleDateFormat\".equals(formatter)) {\n        if (r.annotationField == null) { r.annotationField = r.tokensAnnotationField;  }\n        updateExtractRule(r, env, new ApplyActionWrapper<>(env, new JavaDateFormatExtractor(expr), action));\n      } else {\n        throw new IllegalArgumentException(\"Unsupported formatter: \" + formatter);\n      }\n      return r;\n    }\n  }\n\n  /*\n   * Rules for parsing time specific patterns.\n   * Patterns are similar to time patterns used by JodaTime combined with a simplified regex expression\n   *\n   # y       year                         year          1996                         y\n   # M       month of year                month         July; Jul; 07                M\n   # d       day of month                 number        10                           d\n   # H       hour of day (0~23)           number        0                            H\n   # k       clockhour of day (1~24)      number        24                           k\n   # m       minute of hour               number        30                           m\n   # s       second of minute             number        55                           s\n   # S       fraction of second           number        978                          S (Millisecond)\n   # a       half day of day marker       am/pm","sourceCodeStart":153,"sourceCodeEnd":189,"githubUrl":"https://github.com/stanfordnlp/CoreNLP/blob/1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a/src/edu/stanford/nlp/time/TimeFormatter.java#L153-L189","documentation":"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.","triggerScenarios":"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).","commonSituations":"Porting rules to newer Java and assuming java.time formatters are supported; typos in the formatter string; rules copied from other libraries.","solutions":["Set formatter to exactly \"org.joda.time.format.ISODateTimeFormat\" or \"java.text.SimpleDateFormat\".","If you need java.time patterns, express them as a java.text.SimpleDateFormat pattern in the rule.","Remove the formatter field entirely to use the default parsing path."],"exampleFix":"// before\n{ formatter: \"java.time.format.DateTimeFormatter\", expr: \"yyyy-MM-dd\" }\n// after\n{ formatter: \"java.text.SimpleDateFormat\", expr: \"yyyy-MM-dd\" }","handlingStrategy":"validation","validationCode":"java.util.Set<String> SUPPORTED = new java.util.HashSet<>(\n  java.util.Arrays.asList(\"org.joda.time.format.ISODateTimeFormat\", \"java.text.SimpleDateFormat\"));\nif (formatter != null && !SUPPORTED.contains(formatter))\n  throw new IllegalArgumentException(\"Rule uses unsupported formatter: \" + formatter);","typeGuard":null,"tryCatchPattern":"try {\n  loadRules(ruleFile);\n} catch (IllegalArgumentException e) {\n  if (e.getMessage() != null && e.getMessage().startsWith(\"Unsupported formatter:\")) {\n    log.error(\"Fix formatter field in \" + ruleFile + \": \" + e.getMessage());\n  } else throw e;\n}","preventionTips":["Copy the formatter string verbatim from the two supported values; never abbreviate.","Remember java.time formatters are NOT supported — always express patterns as SimpleDateFormat.","Lint .sutime.txt files at build time."],"tags":["configuration","unsupported-value","rule-file","sutime"],"backgroundTag":"unsupported-enum-value","analyzedSha":"1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a","analyzedAt":"2026-09-10T02:24:07.274Z","contentChangedAt":"2026-09-10T02:24:07.274Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}