{"record":{"id":"589d159ab8176d20","repo":"chinabugotech/hutool","slug":"unparseable-date","errorCode":null,"errorMessage":"Unparseable date: {}","messagePattern":"Unparseable date: (.+?)","errorType":"exception","errorClass":"ParseException","httpStatus":null,"severity":"error","filePath":"hutool-core/src/main/java/cn/hutool/core/date/format/FastDateParser.java","lineNumber":222,"sourceCode":"\t */\n\tprivate void readObject(final ObjectInputStream in) throws IOException, ClassNotFoundException {\n\t\tin.defaultReadObject();\n\n\t\tfinal Calendar definingCalendar = Calendar.getInstance(timeZone, locale);\n\t\tinit(definingCalendar);\n\t}\n\n\t@Override\n\tpublic Date parse(String source) throws ParseException {\n\t\tfinal ParsePosition pp = new ParsePosition(0);\n\t\tfinal Date date = parse(source, pp);\n\t\tif (date == null) {\n\t\t\t// Add a note re supported date range\n\t\t\tif (locale.equals(JAPANESE_IMPERIAL)) {\n\t\t\t\tthrow new ParseException(\"(The \" + locale + \" locale does not support dates before 1868 AD)\\n\" +\n\t\t\t\t\t\t\"Unparseable date: \\\"\" + source, pp.getErrorIndex());\n\t\t\t}\n\t\t\tthrow new ParseException(\"Unparseable date: \" + source, pp.getErrorIndex());\n\t\t}\n\t\treturn date;\n\t}\n\n\t@Override\n\tpublic Date parse(String source, ParsePosition pos) {\n\t\t// timing tests indicate getting new instance is 19% faster than cloning\n\t\tfinal Calendar cal = Calendar.getInstance(timeZone, locale);\n\t\tcal.clear();\n\n\t\treturn parse(source, pos, cal) ? cal.getTime() : null;\n\t}\n\n\t@Override\n\tpublic boolean parse(String source, ParsePosition pos, Calendar calendar) {\n\t\tfinal ListIterator<StrategyAndWidth> lt = patterns.listIterator();\n\t\twhile (lt.hasNext()) {\n\t\t\tfinal StrategyAndWidth strategyAndWidth = lt.next();","sourceCodeStart":204,"sourceCodeEnd":240,"githubUrl":"https://github.com/chinabugotech/hutool/blob/8870454b2a0c29cc6ffd31dcf5667c8ceb2fc442/hutool-core/src/main/java/cn/hutool/core/date/format/FastDateParser.java#L204-L240","documentation":"The generic parse failure: FastDateParser.parse(String, ParsePosition) returned null because the input string did not match the configured pattern (or could not be fully consumed). The exception carries the original source string and the ParsePosition error index.","triggerScenarios":"Calling DateUtil.parse(source, pattern) where source does not conform to pattern; partial matches (e.g. pattern 'yyyy-MM-dd' against '2024/01/01'); trailing characters; non-numeric tokens where numbers expected; out-of-range values (month 13, hour 25).","commonSituations":"Mismatched separators (- vs /), wrong field order, user-typed input, data exported from another system with a different default format, daylight-saving/timezone edge cases producing invalid local times.","solutions":["Align the pattern to the actual input format (verify separators, field lengths, AM/PM markers, timezone tokens).","Normalize/sanitize input before parsing (trim, convert separators).","When multiple formats are possible, try them in sequence or use DateUtil.parse with auto-detection instead of a strict pattern.","Inspect the ParsePosition error index from a lower-level parse call to locate the exact mismatch column."],"exampleFix":"// before\nDate d = DateUtil.parse(\"2024/01/01\", \"yyyy-MM-dd\");\n// after\nDate d = DateUtil.parse(\"2024-01-01\", \"yyyy-MM-dd\");\n// or align pattern to input:\nDate d = DateUtil.parse(\"2024/01/01\", \"yyyy/MM/dd\");","handlingStrategy":"try-catch","validationCode":"void assertMatchesFormat(String src, String pattern){\n  try { new SimpleDateFormat(pattern).parse(src); } catch (ParseException e){ throw new IllegalArgumentException(\"source does not match \"+pattern+\" at col \"+e.getErrorOffset()); }\n}","typeGuard":null,"tryCatchPattern":"try { d = DateUtil.parse(source, pattern); }\ncatch (Exception e) { log.warn(\"bad date '{}', using null\", source); d = null; }","preventionTips":["Sanitize input (trim, normalize separators) before parsing.","When the input format is unknown, try multiple candidate patterns.","Log the error offset to localize mismatches quickly."],"tags":["date","parsing","format-pattern","argument"],"backgroundTag":null,"analyzedSha":"8870454b2a0c29cc6ffd31dcf5667c8ceb2fc442","analyzedAt":"2026-08-14T04:01:12.892Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}