{"record":{"id":"141426c388a70dfe","repo":"FasterXML/jackson-databind","slug":"failed-to-parse-date-value-s-s","errorCode":null,"errorMessage":"Failed to parse Date value '%s': %s","messagePattern":"Failed to parse Date value '(.+?)': (.+?)","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"src/main/java/tools/jackson/databind/DeserializationContext.java","lineNumber":1185,"sourceCode":"     */\n\n    /**\n     * Convenience method for parsing a Date from given String, using\n     * currently configured date format (accessed using\n     * {@link DeserializationConfig#getDateFormat()}).\n     *<p>\n     * Implementation will handle thread-safety issues related to\n     * date formats such that first time this method is called,\n     * date format is cloned, and cloned instance will be retained\n     * for use during this deserialization round.\n     */\n    public Date parseDate(String dateStr) throws IllegalArgumentException\n    {\n        try {\n            DateFormat df = _getDateFormat();\n            return df.parse(dateStr);\n        } catch (ParseException e) {\n            throw new IllegalArgumentException(\"Failed to parse Date value '%s': %s\".formatted(dateStr,\n                    ClassUtil.exceptionMessage(e)));\n        }\n    }\n\n    /**\n     * Convenience method for constructing Calendar instance set\n     * to specified time, to be modified and used by caller.\n     */\n    public Calendar constructCalendar(Date d) {\n        // 08-Jan-2008, tatu: not optimal, but should work for the most part; let's revise as needed.\n        Calendar c = Calendar.getInstance(getTimeZone());\n        c.setTime(d);\n        return c;\n    }\n\n    /*\n    /**********************************************************************\n    /* Extension points for more esoteric data coercion","sourceCodeStart":1167,"sourceCodeEnd":1203,"githubUrl":"https://github.com/FasterXML/jackson-databind/blob/87876ca5c0569b4933aec2d30d6225e4b9ba3a43/src/main/java/tools/jackson/databind/DeserializationContext.java#L1167-L1203","documentation":"Thrown by DeserializationContext.parseDate() when the configured DateFormat (StdDateFormat or a custom DateFormat) cannot parse the input string into a Date. This is a low-level parsing failure that wraps a java.text.ParseException in an IllegalArgumentException, including both the offending value and the underlying parse error message.","triggerScenarios":"Deserializing a JSON string into a java.util.Date or java.util.Calendar field when the string does not match the configured date format. Called internally by date deserializers when ACCEPT_FLOATING_TIMESTAMP or custom date formats are in play. Also triggered directly via ctxt.parseDate(dateStr) in custom deserializers.","commonSituations":"JSON input with ISO-8601 dates when a custom SimpleDateFormat pattern is configured (or vice-versa). Locale/timezone mismatches between the client and server date format. Upgrading from Jackson 2.x default date format to 3.x's stricter StdDateFormat defaults. Missing or incorrect @JsonFormat(pattern=...) on a Date field.","solutions":["Add @JsonFormat(shape = STRING, pattern = \"yyyy-MM-dd\") to the Date field matching your input format.","Configure a global date format: mapper.builder().defaultDateFormat(new SimpleDateFormat(\"yyyy-MM-dd\")).","Enable DeserializationFeature.ADJUST_DATES_TO_CONTEXT_TIME_ZONE if timezone issues are involved.","Provide a custom ValueDeserializer<Date> that tries multiple formats before failing."],"exampleFix":"// before\npublic class Event { public Date timestamp; } // input: \"2024-01-15\" fails with default ISO format\n// after\npublic class Event {\n    @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = \"yyyy-MM-dd\")\n    public Date timestamp;\n}","handlingStrategy":"try-catch","validationCode":"// Pre-validate date strings against your expected format\ntry {\n    new SimpleDateFormat(\"yyyy-MM-dd\").parse(dateStr);\n} catch (ParseException e) {\n    // handle before Jackson tries\n}","typeGuard":null,"tryCatchPattern":"try {\n    mapper.readValue(json, MyType.class);\n} catch (IllegalArgumentException e) {\n    if (e.getMessage().startsWith(\"Failed to parse Date\")) {\n        // log the offending value and return a default or error response\n    }\n}","preventionTips":["Annotate Date fields with @JsonFormat(pattern=...) matching the input.","Set a global default date format on the mapper builder.","Test deserialization with representative date strings from your data."],"tags":["date-parsing","deserialization","date-format","configuration"],"backgroundTag":null,"analyzedSha":"87876ca5c0569b4933aec2d30d6225e4b9ba3a43","analyzedAt":"2026-08-11T12:55:24.033Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}