@JsonFormat LocalDateTime pattern issue

662 views
Skip to first unread message

John Seusy

unread,
Oct 16, 2017, 6:25:54 PM10/16/17
to jackson-user
I am using Jackson 2.7.3 with Java 1.8  and am having an issue getting appropriate behavior out of an @JsonFormat annotated LocalDateTime.

The general configuration of the formatter on these is:

@JsonFormat(shape = JsonFormat.Shape.STRING, pattern="yyyy-MM-dd HH:mm:ss.SSS")
private LocalDateTime recordingEnd;

This format works fine on all of the JSON that I am receiving which comes to me with a matching format.  However I am now generating outbound JSON to an endpoint that is expecting that same format and my outbound JSON following serialization appears to include the 'T' designation even though it is not in the format:

2017-10-13T14:22:33.105

which causes the receiving process to choke.  I am not, currently, at liberty to update the receiving process to expect the 'T', which I had assumed was fairly innocuous, so what options would exist for getting that to disappear from the outbound JSON only without also changing the inbound formats for all these LocalDateTime objects, and also preferably without having to write custom serializers for every object containing a LocalDateTime?

Tatu Saloranta

unread,
Oct 16, 2017, 6:33:18 PM10/16/17
to jackson-user
First things first: please try this with the latest 2.7.x patch to
ensure problem still remains (2.7.9 I think).

-+ Tatu +-
> --
> You received this message because you are subscribed to the Google Groups
> "jackson-user" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to jackson-user...@googlegroups.com.
> To post to this group, send email to jackso...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages