springboot configuration returns the timestamp

Encounter a problem, springboot upgrade to 2.0, received from the database to check out the dates with Date, finally returned directly to the front end, to be able to display properly in Google yyyy browser -MM -DD HH: mm: SS format. But the date is displayed in the IE browser is "garbage" because springboot1.x version of the Date field returns the timestamp, and Google, IE will automatically convert into a timestamp yyyy -MM -DD HH: mm: SS ; after springboot2.0, spring Date field will automatically turn to UTC to the string (in the absence of the configuration), the need to convert the time stamp or date YYYY -MM -dd HH: mm: SS, need Add the following spring configuration, I chose to return the timestamp configuration, successfully resolved the problem.

Configuring the return timestamp

spring
  jackson:
    serialization:
      write-dates-as-timestamps: true

Returns a string global configuration

spring:
    jackson:
        date-format: yyyy-MM-dd HH:mm:ss time-zone: GMT+8

 

 

 

Guess you like

Origin www.cnblogs.com/MopHunter/p/11199676.html