0

I have a java POJO which has a LocalDateTime property. The generated swagger always generates in "2016-01-08T22:34:22.337Z" format, but I don't need that format. Below is what I am trying in the POJO.

@JsonFormat(pattern = DATE_TIME_FORMAT)
private LocalDateTime dateTime;

I have noticed the @JsonFormat is not working at all, even if I remove that, its still defaulting to the above format.

I have even tried with :

@ApiModelProperty(required = true,example = "2016-01-01T09-10-50.ssZ")

Even that is not working.

souvikc
  • 991
  • 1
  • 10
  • 25
  • A `LocalDateTime` does not have an offset or a zone, but the swagger datetime contains a `Z` at the end, which means the time is taken in UTC / +00:00. Can you change it to an `OffsetDateTime`? You can format that as desired… – deHaar Sep 16 '22 at 08:41
  • `LocalDateTime` is not a format, it's a date with certain properties. I think you're also running into issues with the Open Api Spec on dates: https://stackoverflow.com/a/49379235/995891 – zapl Sep 16 '22 at 08:42
  • @deHaar After changing it to OffsetDateTime how do I format that, Using @JsonFormat? – souvikc Sep 16 '22 at 08:51
  • Read [here](https://stackoverflow.com/questions/41876037/jackson-date-format-for-offsetdatetime-in-spring-boot) for example… – deHaar Sep 16 '22 at 09:16

0 Answers0