spring boot中jackson时间格式和东八区的设置

application.properties

# JACKSON (JacksonProperties)
spring.jackson.date-format=yyyy-MM-dd HH:mm:ss
spring.jackson.time-zone=GMT+8

第一个设置就是使用24小时的时间格式;第二个设置就是设置时区为东八区。

bean

	@JsonFormat
	private Date modifyDate;

然后,在你想要格式化的属性上面使用@JsonFormat注解。

后续

如果使用了extends WebMvcConfigurationSupport方式配置,如果想要使用上面的方式配置时间格式,需要将extends WebMvcConfigurationSupport替换为implements WebMvcConfigurer

参考

Appendix A. Common application properties

Custom WebMvcConfiguration breaks Jackson formatting

转载于:https://my.oschina.net/fxtxz2/blog/1861776

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值