项目总结34:SpringMVC字符串时间转Timestamp

项目总结34:SpringMVC字符串时间转Timestamp

SpringMVC接收时间,如果不处理,汇报异常,处理方案如下:

1-接口请求参数,POST, application/json格式

{"startTime":"2019-09-27 19:00:00"}

2-controller使用@RequestBody+实体类 接收请求参数

3-实体类中参数加上注解

    @JsonFormat(pattern="yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
    private Timestamp startTime;

 

原文地址:https://www.cnblogs.com/wobuchifanqie/p/11600298.html