{"record":{"id":"4a4f494a3a0759f2","repo":"OpenRefine/OpenRefine","slug":"extra-value-val-in-date-datestr","errorCode":null,"errorMessage":"Extra value \"<val>\" in date \"<dateStr>\"","messagePattern":"Extra value \"<val>\" in date \"<dateStr>\"","errorType":"exception","errorClass":"CalendarParserException","httpStatus":null,"severity":"error","filePath":"modules/core/src/main/java/com/google/refine/expr/util/CalendarParser.java","lineNumber":1233,"sourceCode":"     * \n     * @param dateStr\n     *            full date string\n     * @param state\n     *            parser state\n     * @param val\n     *            numeric value to use\n     * \n     * @throws CalendarParserException\n     *             if there was a problem parsing the token\n     */\n    private static final void parseNumericToken(String dateStr,\n            ParserState state, int val) throws CalendarParserException {\n        // puke if we've already found 3 values\n        if (state.isYearSet() && state.isMonthSet() && state.isDateSet()) {\n            if (DEBUG) {\n                System.err.println(\"*** Extra number \" + val);\n            }\n            throw new CalendarParserException(\"Extra value \\\"\" + val\n                    + \"\\\" in date \\\"\" + dateStr + \"\\\"\");\n        }\n\n        // puke up on negative numbers\n        if (val < 0) {\n            if (DEBUG) {\n                System.err.println(\"*** Negative number \" + val);\n            }\n            throw new CalendarParserException(\"Found negative number in\"\n                    + \" date \\\"\" + dateStr + \"\\\"\");\n        }\n\n        if (val > 9999) {\n            parseNumericBlob(dateStr, state, val);\n            return;\n        }\n\n        // deal with obvious years first","sourceCodeStart":1215,"sourceCodeEnd":1251,"githubUrl":"https://github.com/OpenRefine/OpenRefine/blob/a946177e049f3b0644261661db36cbb0c81ccf8a/modules/core/src/main/java/com/google/refine/expr/util/CalendarParser.java#L1215-L1251","documentation":"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.","triggerScenarios":"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\".","commonSituations":"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.","solutions":["Remove or split the extra numeric tokens so only one y/m/d triple remains per parse call.","Format times with a colon (10:30) so the parser treats them as times rather than extra numbers.","Catch CalendarParserException and parse the first date match found by a regex."],"exampleFix":"// before\nCalendarParser.parse(\"1/1/2020 - 12/31/2020\"); // throws: Extra value\n// after\nString[] parts = range.split(\"\\\\s*-\\\\s*\");\nCalendar start = CalendarParser.parse(parts[0]);","handlingStrategy":"validation","validationCode":"long numericTokens = java.util.regex.Pattern.compile(\"\\\\b\\\\d+\\\\b\").matcher(dateStr).results().count();\nif (numericTokens > 3) { /* split ranges or strip extras before parsing */ }","typeGuard":null,"tryCatchPattern":"try {\n    return CalendarParser.parse(dateStr);\n} catch (CalendarParserException e) {\n    if (e.getMessage().startsWith(\"Extra value\")) {\n        return parseRangeAsList(dateStr); // split on '-' or '/' boundaries and parse each\n    }\n    throw e;\n}","preventionTips":["Split date ranges into individual endpoints before parsing.","Write times with colons (10:30) so they are not counted as numeric date tokens.","Separate IDs and quantities from date fields in your data model."],"tags":["date-parsing","java","tokenization"],"backgroundTag":"invalid-date-format","analyzedSha":"a946177e049f3b0644261661db36cbb0c81ccf8a","analyzedAt":"2026-09-08T10:21:27.735Z","contentChangedAt":"2026-09-08T10:21:27.735Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}