eclipse-ee4j / eclipse-ee4j/yasson
Deserialize ISO_DATE to java.util.Date not supported
- Dominant language
- Java
- Stars
- 218
- Forks
- 109
- Avg merge
- 1d 5h
- Merged PRs (30d)
- 9
Description
**Describe the bug**
From the JSON-B specification:
> Implementations MUST support deserialization of both ISO_DATE and ISO_DATE_TIME into
java.util.Date, Calendar and GregorianCalendar instances.
The JavaDoc on the `java.time.format.DateTimeFormatter.ISO_DATE` format contains the following comment, indicating that '2011-12-03' is a valid ISO_DATE formatted date.
> The ISO date formatter that formats or parses a date with the offset if available, such as '2011-12-03' or '2011-12-03+01:00'.
But when I run the following with Yasson:
```
System.out.println(jsonb.fromJson("2011-12-03", Date.class));
```
I get an error:
> Caused by: java.time.format.DateTimeParseException: Text '2011' could not be parsed at index 4
**To Reproduce**
```
System.out.println(jsonb.fromJson("2020-03-11", Date.class));
```
**Expected behavior**
A `Date` object instead of an error.
**System information:**
- OS: macOS
- Java Version: 8 & 11
- Yasson Version: 1.0.6
Contributor guide
Research direction
Start by running the reported jsonb.fromJson("2020-03-11", Date.class) reproduction and trace the ISO_DATE deserialization path that produces the DateTimeParseException. Compare the behavior with the JSON-B requirement for java.util.Date; done means an ISO date string returns a Date object without an error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- backend-api-design
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100