Cannot deserialize value of type X from String
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.
{
"id": 7,
"orderDate": "14/10/2026"
}public class Order {
public long id;
public Date orderDate;
}
Order order = mapper.readValue(json, Order.class);Lines 2, 3 and 4 change.
public class Order {
public long id;
@JsonFormat(pattern = "dd/MM/yyyy")
public Date orderDate;
}
Order order = mapper.readValue(json, Order.class);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.
- 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
A date format Jackson does not read
The example sends
"14/10/2026"to ajava.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.Text in a number field
"abc"for anintgives the same kind of message:from String "abc": not a valid, then the type. The end of the message names the field,quantity.An empty string in a number field
""for anintdepends on the version. Jackson 2 reads it with no error. Jackson 3 throwsCannot coerceand tells you to disableDeserializationFeature.FAIL_ON_NULL_FOR_PRIMITIVESif you want to allow it. So moving from Jackson 2 to 3 can turn a request that used to work into an error.Spring shows the value but not where
Spring prints
JSON parse error:and the message above, without theat [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.