jakartaee / jakartaee/jsonb-api
Customize date format of different Java date types
- Dominant language
- Java
- Stars
- 95
- Forks
- 41
- Avg merge
- 1d 6h
- Merged PRs (30d)
- 35
Description
In the JSON-B 1.0 specification, section 3.5, it supports ALL the native date types of Java like java.util.date, java.time.LocalDate and java.time.LocalTime. HOWEVER, in the [JsonConfig](https://github.com/javaee/jsonb-spec/blob/1.0/api/src/main/java/javax/json/bind/JsonbConfig.java), it ONLY provide a single withDateFormat() method (section 4.8) to apply the global custom date format which will make ALL supported date type to use this format.
BUT, there will be a problem if your application use different different date types such as java.util.Date, java.time.LocalDate and java.time.LocalTime. Because when you define the
> yyyy-MM-dd
in withDateFormat(), there will be an exception thrown if the object has java.time.LocalTime field.
So, I think it maybe better to allow the client to configure the date format by different date type => e.g:
- withDateFormat(java.util.Date, dateFormat, Locale)
- withDateFormat(java.time.LocalDate, dateFormat, Locale)
- ...
What do you think about it?
Thank you.
Contributor guide
Research direction
Start with JSON-B 1.0 specification sections 3.5 and 4.8 and api/src/main/java/javax/json/bind/JsonbConfig.java. Compare the global withDateFormat behavior for java.util.Date, java.time.LocalDate, and java.time.LocalTime, then define a per-date-type configuration design whose expected result is separate formats without exceptions.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- api, backend-api-design
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100