Groups keyboard shortcuts have been updated
Dismiss
See shortcuts

Jackson and SerializationFeature.WRITE_DATES_AS_TIMESTAMPS

1,593 views
Skip to first unread message

Bernhard Lutzmann

unread,
Feb 13, 2021, 1:25:48 PM2/13/21
to Quarkus Development mailing list
Hi,

is there a deeper reason why the SerializationFeature WRITE_DATES_AS_TIMESTAMPS is not disabled by default?

Currently, a LocalDate is serialized to an array, e. g. [2021, 2, 13].
With WRITE_DATES_AS_TIMESTAMPS disabled it is a string, e. g. "2021-02-13".

Similar for LocalDateTime.

Furthermore, in Swagger UI the generated "Example Value" is showing a LocalDate as "2021-02-13" even if the actual returned value is an array.

Bernhard

Ken Yee

unread,
Feb 13, 2021, 3:34:27 PM2/13/21
to bernhard...@gmail.com, Quarkus Development mailing list
Guessing it's because dates over REST APIs should be ISO8601 formatted...

--
You received this message because you are subscribed to the Google Groups "Quarkus Development mailing list" group.
To unsubscribe from this group and stop receiving emails from it, send an email to quarkus-dev...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/quarkus-dev/8b513194-80d7-42ec-97ef-0f506beea07an%40googlegroups.com.

Bernhard Lutzmann

unread,
Feb 16, 2021, 2:09:08 PM2/16/21
to Quarkus Development mailing list
The point is: currently LocalDate and LocalDateTime are not ISO8601 formatted by default.

I have seen developers (including me) running into this issue more then once. Misleading is also the different format that Swagger shows.

Spring is also disabling SerializationFeature.WRITE_DATES_AS_TIMESTAMPS by default:

IMHO, it would bringe more "developer joy" if dates/times are formatted this way out-of-the-box.

Cheers,
Bernhard

Georgios Andrianakis

unread,
Feb 16, 2021, 2:32:03 PM2/16/21
to bernhard...@gmail.com, Quarkus Development mailing list
I personally think it makes sense.

It would be a breaking change, but I think it's warranted

Guillaume Smet

unread,
Feb 16, 2021, 2:36:23 PM2/16/21
to Georgios Andrianakis, bernhard...@gmail.com, Quarkus Development mailing list
I was replying the same.

I think we could change it as long as we introduce a configuration property similar to what I did here: https://github.com/quarkusio/quarkus/blob/master/extensions/jackson/runtime/src/main/java/io/quarkus/jackson/runtime/JacksonBuildTimeConfig.java#L15
to easily go back to the previous behavior.

I can work on that tomorrow, I need easy things as it's release day! 

Georgios Andrianakis

unread,
Feb 16, 2021, 2:39:17 PM2/16/21
to Guillaume Smet, bernhard...@gmail.com, Quarkus Development mailing list


On Tue, Feb 16, 2021, 21:36 Guillaume Smet <guillau...@gmail.com> wrote:
I was replying the same.

I think we could change it as long as we introduce a configuration property similar to what I did here: https://github.com/quarkusio/quarkus/blob/master/extensions/jackson/runtime/src/main/java/io/quarkus/jackson/runtime/JacksonBuildTimeConfig.java#L15
to easily go back to the previous behavior.

I can work on that tomorrow, I need easy things as it's release day! 

Cool, ping me for a review then 😉

Guillaume Smet

unread,
Feb 17, 2021, 6:50:37 AM2/17/21
to Georgios Andrianakis, bernhard...@gmail.com, Quarkus Development mailing list
Reply all
Reply to author
Forward
0 new messages