FasterXML/jackson-databind · error · IllegalArgumentException

Failed to parse Date value

Error message

Failed to parse Date value '%s': %s

What it means

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.

Solutions

  1. Add @JsonFormat(shape = STRING, pattern = "yyyy-MM-dd") to the Date field matching your input format.
  2. Configure a global date format: mapper.builder().defaultDateFormat(new SimpleDateFormat("yyyy-MM-dd")).
  3. Enable DeserializationFeature.ADJUST_DATES_TO_CONTEXT_TIME_ZONE if timezone issues are involved.
  4. Provide a custom ValueDeserializer<Date> that tries multiple formats before failing.

Example fix

// before
public class Event { public Date timestamp; } // input: "2024-01-15" fails with default ISO format
// after
public class Event {
    @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd")
    public Date timestamp;
}
Defensive patterns

Strategy: try-catch

Validate before calling

// Pre-validate date strings against your expected format
try {
    new SimpleDateFormat("yyyy-MM-dd").parse(dateStr);
} catch (ParseException e) {
    // handle before Jackson tries
}

Try / catch

try {
    mapper.readValue(json, MyType.class);
} catch (IllegalArgumentException e) {
    if (e.getMessage().startsWith("Failed to parse Date")) {
        // log the offending value and return a default or error response
    }
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Understand the failure class

Related errors


AI-assisted analysis of FasterXML/jackson-databind@87876ca5c0 (2026-08-11). Data as JSON: /api/errors/141426c388a70dfe. Report an issue: GitHub.

Appendix: source

Thrown at src/main/java/tools/jackson/databind/DeserializationContext.java:1185

     */

    /**
     * Convenience method for parsing a Date from given String, using
     * currently configured date format (accessed using
     * {@link DeserializationConfig#getDateFormat()}).
     *<p>
     * Implementation will handle thread-safety issues related to
     * date formats such that first time this method is called,
     * date format is cloned, and cloned instance will be retained
     * for use during this deserialization round.
     */
    public Date parseDate(String dateStr) throws IllegalArgumentException
    {
        try {
            DateFormat df = _getDateFormat();
            return df.parse(dateStr);
        } catch (ParseException e) {
            throw new IllegalArgumentException("Failed to parse Date value '%s': %s".formatted(dateStr,
                    ClassUtil.exceptionMessage(e)));
        }
    }

    /**
     * Convenience method for constructing Calendar instance set
     * to specified time, to be modified and used by caller.
     */
    public Calendar constructCalendar(Date d) {
        // 08-Jan-2008, tatu: not optimal, but should work for the most part; let's revise as needed.
        Calendar c = Calendar.getInstance(getTimeZone());
        c.setTime(d);
        return c;
    }

    /*
    /**********************************************************************
    /* Extension points for more esoteric data coercion

View on GitHub (pinned to 87876ca5c0)