vavr-io / vavr-jackson

Jackson datatype module for Vavr
Apache License 2.0
97 stars 35 forks source link

Serialize of Liste of Date does not follow pattern defined in @JsonFormat #154

Closed camory closed 4 years ago

camory commented 4 years ago

Hello, I am facing the same issue as described in #141 but with List. I have a DTO with a List java.util.Date with a custom date format:

    @JsonFormat(pattern = "yyyy-MM-dd", timezone = "Europe/Paris")
    private final List<Date> dates;

When serializing, the date format is not taken into account. It works when replacing the io.vavr.collections.List by java.util.List.

mincong-h commented 4 years ago

Thanks for creating this issue, @camory . I confirm that this is a bug. I'm working on a fix.

mincong-h commented 4 years ago

@camory , I have a fix for your issue, see #155

However, after the fix, I think you still need to modify your code to make it works. You need to provide the shape:

+    @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd", timezone = "Europe/Paris")
-    @JsonFormat(pattern = "yyyy-MM-dd", timezone = "Europe/Paris")
     private final List<Date> dates;