jakartaee / jakartaee/jsonb-api
Feature Request: Mandate support for `java.time.Year`, `YearMonth`, and `MonthDay` in default date mappings
- Dominant language
- Java
- Stars
- 95
- Forks
- 41
- Avg merge
- 1d 6h
- Merged PRs (30d)
- 35
Description
Similar to https://github.com/jakartaee/faces/issues/2211, add more Java 8 DateTime type support.
#### Description
Section 3.5 (Dates) of the Jakarta JSON Binding specification requires all implementations to support a robust selection of traditional and modern Java Date-Time API classes (such as `Instant`, `LocalDate`, `Duration`, etc.).
However, the specification does not explicitly address lower-precision temporal types from the `java.time` package, specifically:
* `java.time.Year`
* `java.time.YearMonth`
* `java.time.MonthDay`
As a result, behavior for these types across runtime implementations is inconsistent, forcing developers to build boilerplate `JsonbAdapter` classes for simple objects like credit card expiration dates (`YearMonth`).
#### Proposed Enhancement
Formally add `java.time.Year`, `java.time.YearMonth`, and `java.time.MonthDay` to the mandated types listed in Section 3.5.
The default ISO-8601 string formatting behaviors should be explicitly outlined to prevent parsing failures:
* `java.time.Year` -> serialized/deserialized as string format `"yyyy"`
* `java.time.YearMonth` -> serialized/deserialized as string format `"yyyy-MM"`
* `java.time.MonthDay` -> serialized/deserialized as string format `"--MM-dd"`
#### Additional Context
Adding native support for these types would bridge the final gaps of the Java 8 Date-Time API within modern JSON-B environments. It would provide the same out-of-the-box convenience currently enjoyed by `LocalDate` and `LocalDateTime` users.
Contributor guide
Research direction
Start with Section 3.5 (Dates) of the Jakarta JSON Binding specification and compare the related Jakarta Faces issue 2211. Define how Year, YearMonth, and MonthDay should be covered, including their stated ISO-8601 formats; done means the specification proposal is complete and unambiguous.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- backend-api-design
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100