1.时间戳
@JsonFormat(pattern = "yyyy-MM-dd",timezone="Asia/Shanghai")
@ApiParam(value = "创建时间", hidden = false)
private Timestamp createTime;
传的json数据
{
"createTime": "2020-12-1"
}
生效
{
"createTime": "2020-12-1 00:00:01"
}
生效
改成@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone="Asia/Shanghai")
{
"createTime": "2020-12-1 00:00:01"
}
生效
{
"createTime": "2020-12-1"
}
不生效
2.LocalDateTime
1)@JsonFormat(pattern = "yyyy-MM-dd",timezone="Asia/Shanghai")
{
"toDate": "2020-12-14 00:00:00"
}
{
"toDate": "2020-12-14"
}
均不生效
2)@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone="Asia/Shanghai")
1.
{
"toDate": "2020-12-01 00:00:01"
}
生效
2.
{
"toDate": "2020-12-1 00:00:01"
}
01日改成1日,不生效.
3.
{
"toDate": "2020-12-01"
}
去掉HH:mm:ss,不生效.