OpenRefine/OpenRefine · error · CalendarParserException

Extra value " " in date

Error message

Extra value "<val>" in date "<dateStr>"

What it means

parseNumericToken enforces a maximum of three numeric components: if year, month, and day are all already set and another number token arrives, there is no slot left, so it throws this CalendarParserException quoting the surplus value. The parser's model holds exactly one year, one month, and one day.

Solutions

  1. Remove or split the extra numeric tokens so only one y/m/d triple remains per parse call.
  2. Format times with a colon (10:30) so the parser treats them as times rather than extra numbers.
  3. Catch CalendarParserException and parse the first date match found by a regex.

Example fix

// before
CalendarParser.parse("1/1/2020 - 12/31/2020"); // throws: Extra value
// after
String[] parts = range.split("\\s*-\\s*");
Calendar start = CalendarParser.parse(parts[0]);
Defensive patterns

Strategy: validation

Validate before calling

long numericTokens = java.util.regex.Pattern.compile("\\b\\d+\\b").matcher(dateStr).results().count();
if (numericTokens > 3) { /* split ranges or strip extras before parsing */ }

Try / catch

try {
    return CalendarParser.parse(dateStr);
} catch (CalendarParserException e) {
    if (e.getMessage().startsWith("Extra value")) {
        return parseRangeAsList(dateStr); // split on '-' or '/' boundaries and parse each
    }
    throw e;
}

Prevention

When it happens

Trigger: CalendarParser.parse() on strings with four or more numeric tokens, e.g. "01/02/03/04", "2020 5 17 10" (date plus time components without a colon), or "12 25 2020 30".

Common situations: Cells containing ranges ('1/1/2020 - 12/31/2020' parsed as one token stream), timestamps without colons, or version-like numbers ('2.4.1.7') in date columns.

Related errors


AI-assisted analysis of OpenRefine/OpenRefine@a946177e04 (2026-09-08). Data as JSON: /api/errors/4a4f494a3a0759f2. Report an issue: GitHub.

Appendix: source

Thrown at modules/core/src/main/java/com/google/refine/expr/util/CalendarParser.java:1233

     * 
     * @param dateStr
     *            full date string
     * @param state
     *            parser state
     * @param val
     *            numeric value to use
     * 
     * @throws CalendarParserException
     *             if there was a problem parsing the token
     */
    private static final void parseNumericToken(String dateStr,
            ParserState state, int val) throws CalendarParserException {
        // puke if we've already found 3 values
        if (state.isYearSet() && state.isMonthSet() && state.isDateSet()) {
            if (DEBUG) {
                System.err.println("*** Extra number " + val);
            }
            throw new CalendarParserException("Extra value \"" + val
                    + "\" in date \"" + dateStr + "\"");
        }

        // puke up on negative numbers
        if (val < 0) {
            if (DEBUG) {
                System.err.println("*** Negative number " + val);
            }
            throw new CalendarParserException("Found negative number in"
                    + " date \"" + dateStr + "\"");
        }

        if (val > 9999) {
            parseNumericBlob(dateStr, state, val);
            return;
        }

        // deal with obvious years first

View on GitHub (pinned to a946177e04)