Cannot deserialize value of type X from String

ErrorJava

com.fasterxml.jackson.databind.exc.InvalidFormatException: Cannot deserialize value of type `java.util.Date` from String "14/10/2026": not a valid representation (error: Failed to parse Date value '14/10/2026': Cannot parse date "14/10/2026": not compatible with any of standard forms ("yyyy-MM-dd'T'HH:mm:ss.SSSX", "yyyy-MM-dd'T'HH:mm:ss.SSS", "EEE, dd MMM yyyy HH:mm:ss zzz", "yyyy-MM-dd"))

What it means

The JSON has a string Jackson cannot turn into the Java type, here 14/10/2026 going into a java.util.Date. Tell Jackson the format with @JsonFormat(pattern = "dd/MM/yyyy"), or have the sender use a format Jackson already reads.

Last verified on Jackson 2.21 and 3.1; Spring 6.2 and 7.0.

This JSON is valid. The problem is on the Java side, so a JSON validator would say it is fine.

Usually
A date format Jackson does not readText in a number fieldAn empty string in a number fieldSpring shows the value but not where
Fix
Tell Jackson the format.

The fix

Tell Jackson the format. For a date, put @JsonFormat(pattern = "dd/MM/yyyy") on the field, as in the fixed code. Or have the sender use a format Jackson already reads, like 2026-10-14. For a number field, the sender has to send a number.

The JSON that was sent: request.jsonValid JSON
{
  "id": 7,
  "orderDate": "14/10/2026"
}
A JSON validator says this is fine.
Broken.javaThrows
public class Order {
  public long id;
  public Date orderDate;
}

Order order = mapper.readValue(json, Order.class);
Throws InvalidFormatException

Lines 2, 3 and 4 change.

Fixed.javaWorks
public class Order {
  public long id;

  @JsonFormat(pattern = "dd/MM/yyyy")
  public Date orderDate;
}

Order order = mapper.readValue(json, Order.class);
Reads without an error.

How the message appears

Jackson 2, then Jackson 3, then Spring (the same on 6.2 and 7.0). The last two are other cases: text in an int field, and an empty string in an int field, which only Jackson 3 rejects.

Console
  • com.fasterxml.jackson.databind.exc.InvalidFormatException: Cannot deserialize value of type `java.util.Date` from String "14/10/2026": not a valid representation (error: Failed to parse Date value '14/10/2026': Cannot parse date "14/10/2026": not compatible with any of standard forms ("yyyy-MM-dd'T'HH:mm:ss.SSSX", "yyyy-MM-dd'T'HH:mm:ss.SSS", "EEE, dd MMM yyyy HH:mm:ss zzz", "yyyy-MM-dd"))
  • at [Source: REDACTED (`StreamReadFeature.INCLUDE_SOURCE_IN_LOCATION` disabled); line: 3, column: 16] (through reference chain: com.example.Order["orderDate"])
  • tools.jackson.databind.exc.InvalidFormatException: Cannot deserialize value of type `java.util.Date` from String "14/10/2026": not a valid representation (error: Failed to parse Date value '14/10/2026': Cannot parse date "14/10/2026": not compatible with any of standard forms ("yyyy-MM-dd'T'HH:mm:ss.SSSX", "yyyy-MM-dd'T'HH:mm:ss.SSS", "EEE, dd MMM yyyy HH:mm:ss zzz", "yyyy-MM-dd"))
  • at [Source: REDACTED (`StreamReadFeature.INCLUDE_SOURCE_IN_LOCATION` disabled); byte offset: #UNKNOWN] (through reference chain: com.example.Order["orderDate"])
  • org.springframework.http.converter.HttpMessageNotReadableException: JSON parse error: Cannot deserialize value of type `java.util.Date` from String "14/10/2026": not a valid representation (error: Failed to parse Date value '14/10/2026': Cannot parse date "14/10/2026": not compatible with any of standard forms ("yyyy-MM-dd'T'HH:mm:ss.SSSX", "yyyy-MM-dd'T'HH:mm:ss.SSS", "EEE, dd MMM yyyy HH:mm:ss zzz", "yyyy-MM-dd"))
  • Cannot deserialize value of type `int` from String "abc": not a valid `int` value
  • Cannot coerce `null` to `int` value (disable `DeserializationFeature.FAIL_ON_NULL_FOR_PRIMITIVES` to allow)

What causes it

  1. A date format Jackson does not read

    The example sends "14/10/2026" to a java.util.Date. The message lists the formats Jackson tried: "yyyy-MM-dd'T'HH:mm:ss.SSSX", "yyyy-MM-dd'T'HH:mm:ss.SSS", "EEE, dd MMM yyyy HH:mm:ss zzz" and "yyyy-MM-dd". A day-first date is none of them.

  2. Text in a number field

    "abc" for an int gives the same kind of message: from String "abc": not a valid, then the type. The end of the message names the field, quantity.

  3. An empty string in a number field

    "" for an int depends on the version. Jackson 2 reads it with no error. Jackson 3 throws Cannot coerce and tells you to disable DeserializationFeature.FAIL_ON_NULL_FOR_PRIMITIVES if you want to allow it. So moving from Jackson 2 to 3 can turn a request that used to work into an error.

  4. Spring shows the value but not where

    Spring prints JSON parse error: and the message above, without the at [Source: ...] line. The value is still there, so you can see what the client really sent. Other Spring messages are on the Spring page.

Worth knowing

Watch outA date like 03/04/2026 is 3 April or 4 March depending on who sent it. Agree the format with the sender and write it down.

Your JSON and text are processed entirely in your browser and are never sent anywhere. To understand how the site is used we record each page view (the page, the referrer and an approximate location from your IP address) and keep it for 90 days. Nothing is stored on your device unless you choose it. Accept to also store a device identifier here and record your browser and device characteristics, which is what lets a return visit be told from a new one. Decline and nothing is sent at all. We respect Do Not Track. See our privacy policy.