1

In my springboot applicaiton, serialization date format pattern = 'yyyy-MM-dd HH:mm:ss', and I want to deserialization date format pattern = 'yyyy-MM-dd'.

In the application.yml:

spring:
  jackson:
    timezone: "GMT+8"
    date-format: "yyyy-MM-dd HH:mm:ss"

But, This is global and works for both serialization and deserialization.

What should I do?

Stephen.lin
  • 166
  • 1
  • 12
  • 1
    You should configure it manually on the getter and setter of the field itself. – Patrick Jul 14 '21 at 12:46
  • What do you mean you want 'yyyy-MM-dd'? That you want a LocalDate as object instead of a LocalDateTime? Deserializing will not get any format, it will be populated into an object. – Franjavi Jul 15 '21 at 11:25
  • I know that @JsonFormat can be configured on bean properties, is there a similar global configuration method. Because I have many bean objects – Stephen.lin Jul 15 '21 at 12:32

0 Answers0