Grails——AS JSON后时间时区存在问题

在bootstrap中配置时间

class BootStrap {

     def init = { servletContext ->
         JSON.registerObjectMarshaller(Date) {
            //use any format as you want
            return it?.format("yyyy-MM-dd HH:mm:ss")
         }
     }
     def destroy = {
     }
}

原文连接:
https://stackoverflow.com/questions/39644593/value-of-date-object-in-a-map-is-changed-in-a-grails-controller-while-using-as

你可能感兴趣的:(Grails——AS JSON后时间时区存在问题)