最近在学习Spring Boot,配置确实简化了,但是还有些考虑不够合适之处。
RestController中json输出日期的问题
默认输出为TIMESTAMP时间戳格式
{"id":1,"content":"Hello, World!","created":1425300054855,"guid":"547fc545-e246-4243-96f5-fce21c7626db"}
-->
可读日期格式
{"id":1,"content":"Hello, World!","created":"2015-03-02T21:46:45+08:00","guid":"53526823-0b50-4915-9194-4a63908999e1"}
application.properties 设定
spring.jackson.date-format=yyyy-MM-dd HH:mm:ssXXX
末尾XXX为时区标识,形如+08:00
参考:
1)http://wiki.fasterxml.com/JacksonFAQDateHandling
2)Spring Boot Reference 附录A中 spring.jackson.date-format