Mittwoch, 21. März 2018

How to map a java.util.Date to a specific JSON java.lang.String - Date Serialization with Jackson 2.8.4

I do prefer Jackson for serializing and deserializing from and to JSON.

For Date to String conversion you do only need one simple annotation:


import com.fasterxml.jackson.annotation.JsonFormat;

// "2018-03-02T12:00:00";
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyy-MM-dd'T'HH:mm:ss")
public Date TimeStamp;

Keine Kommentare:

Kommentar veröffentlichen

NEW BLOG! http://cleancode.consulting/

Dear Reader, This Blog is closed and remains as an archive. Please find our new Blog at  http://cleancode.consulting/