Pramod
Pramod

Reputation: 731

How to format the json Date format using spring boot and spring hateoas

I am working on spring boot and spring hateoas for creating a rest api.
I need to format the date format to "yyyy-MM-dd".

I do not want to make use of @JsonFormat, because this annotation has to be used everywhere we use a Date.

So kindly help me out to achieve this configuration globally, instead of making use of @JsonFormat everywhere.

Upvotes: 2

Views: 1930

Answers (1)

adam p
adam p

Reputation: 1214

As per the documentation If you're using jackson, you can set the date format globally by setting the following value in your application.properties/application.yml:

spring.jackson.date-format= # Date format string (e.g. yyyy-MM-dd HH:mm:ss), or a fully-qualified date format class name (e.g. com.fasterxml.jackson.databind.util.ISO8601DateFormat)

Upvotes: 5

Related Questions