jakartaee / jakartaee/jsonb-api
Time as seconds since 1970
- Dominant language
- Java
- Stars
- 95
- Forks
- 41
- Avg merge
- 1d 6h
- Merged PRs (30d)
- 35
Description
Quite a few JSON formats represent times as the number of seconds since 1970. It would be useful to be able to bind these to a java.time.Instant.
JSON-B offers [JsonbDateFormat.TIME_IN_MILLIS](http://json-b.net/docs/api/java.json.bind/javax/json/bind/annotation/JsonbDateFormat.html#TIME_IN_MILLIS), which is close to the required functionality. How about specifying JsonbDateFormat.TIME_IN_SECONDS?
Deserialization needs to accept any JSON number format (eg 1558403222 and 1558403222.888 and 1.558403222888e9). A serialization option that only used "integer" format could be useful for compatibility: no decimal point; no scientific notation; only second resolution (eg 1558403222).
As an example of the need for this feature is the [JSON Web Token (JWT) [RFC 7519]](https://tools.ietf.org/html/rfc7519#page-6) specification, which defines "issued at" and "not before" members of type NumericDate.
> NumericDate
> A JSON numeric value representing the number of seconds from
> 1970-01-01T00:00:00Z UTC until the specified UTC date/time,
> ignoring leap seconds. This is equivalent to the IEEE Std 1003.1,
> 2013 Edition [POSIX.1] definition "Seconds Since the Epoch", in
> which each day is accounted for by exactly 86400 seconds, other
> than that non-integer values can be represented. See RFC 3339
> [RFC3339] for details regarding date/times in general and UTC in
> particular.
Contributor guide
Research direction
Start with the JsonbDateFormat API referenced in the issue and review how TIME_IN_MILLIS is defined and used. The feature is done when java.time.Instant can deserialize JSON numbers in integer, decimal, and scientific notation as epoch seconds, with an optional integer-seconds serialization format.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- api
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100