Cannot deserialize value of type java.util.Date from String
Data Structures & Algorithms practice on Codemia
Step through 300+ coding interview problems with animated visualisers that show the data structure changing as the code runs. The Blind 75 are free.
Introduction
This Jackson error appears when the JSON payload contains a date string that does not match the format expected for a java.util.Date field. The fix is usually straightforward once you decide what date shape your API accepts and configure deserialization to match that contract in one place.
Why Jackson Rejects the String
Jackson can deserialize dates in several ways, but it still needs an unambiguous rule. If your payload sends an ISO 8601 string such as 2026-03-07T14:30:00Z while your mapper expects a numeric timestamp or a different pattern, Jackson has no safe conversion path and throws the exception.
Here is a minimal example that fails when the mapper is not configured for the incoming string format:
The problem is not that java.util.Date cannot represent the timestamp. The problem is that Jackson needs to know exactly how to parse the text before it can create the Date object.
Fix One Field with @JsonFormat
If only one field uses a specific format, annotate that field directly. This keeps the parsing rule close to the DTO and makes the payload contract visible to anyone reading the class.
Now the same JSON string can be deserialized reliably:
This option is a good fit when the field has a stable format and you do not want global mapper settings to affect unrelated DTOs.
Configure One Global Date Contract
If your entire API uses one date format, configure the ObjectMapper once and reuse it everywhere. That prevents drift between controllers, tests, and background jobs.
Global configuration is powerful, but it only works well when your service truly has one date contract. If one endpoint accepts MM/dd/yyyy and another accepts ISO 8601, field-level annotations or custom deserializers are usually clearer.
Prefer java.time in New Code
java.util.Date can work, but it does not express timezone intent clearly. For new code, Instant, OffsetDateTime, or LocalDate usually communicate the API contract more precisely. Jackson handles these types well when you register JavaTimeModule.
This version is usually easier to reason about because the type itself tells you whether an offset is expected.
Handle Legacy Formats with a Custom Deserializer
Sometimes the upstream system sends dates in a format you cannot change. In that case, write a custom deserializer instead of scattering ad hoc parsing logic through service code.
Attach it to the field like this:
That keeps the weird format isolated and makes future cleanup easier.
Common Pitfalls
Using java.util.Date with no explicit format and assuming Jackson will guess correctly is the most common mistake. Another frequent problem is mixing local times and UTC timestamps in the same API, which makes debugging much harder than the original exception. Teams also forget to register JavaTimeModule after moving to OffsetDateTime, which creates a different deserialization failure that looks unrelated at first glance. Finally, tests often cover only a happy-path date string and miss null values, invalid inputs, or timestamps with different offsets.
Summary
- This error means the incoming date string does not match Jackson's parsing rules for the target field.
- Use
@JsonFormatwhen one field has a specific string format. - Configure the
ObjectMapperglobally only when your whole API shares one date contract. - Prefer
java.timetypes for new code because they express time semantics more clearly. - Use a custom deserializer when you must accept a legacy format you cannot change.
Related reading
- Cannot disable Spring Cloud Config via spring.cloud.config.enabledfalse
- Cannot find MessageMatcherDelegatingAuthorizationManager class while trying to configure websocket security in Spring Boot 3
- Cannot get maven project.version property in a Spring application with Value
- Cannot inline bytecode built with JVM target 1.8 into bytecode that is being built with JVM target 1.6
- Cannot determine the organization name for this 'dev.azure.com' remote URL
- Cannot dlopen some GPU libraries. Skipping registering GPU devices
- Cannot invoke org.springframework.web.servlet.mvc.condition.PatternsRequestCondition.getPatterns because this.condition is null
- Cannot load driver class org.h2.Driver in spring boot application

OOD Fundamentals
Master object-oriented design from first principles, SOLID, design patterns, and classic interview problems with hands-on coding.
View the courseTrack what you have practised
A free account saves your progress, solutions and study plan across every problem on Codemia.
Data Structures & Algorithms practice on Codemia
Step through 300+ coding interview problems with animated visualisers that show the data structure changing as the code runs. The Blind 75 are free.