1. 程式人生 > >springmvc json轉對象時日期轉化

springmvc json轉對象時日期轉化

val json post mapping format test eth map .com

spring mvc 默認用的是 jackson 來解析 json 的,所以 Date 的解析得下面這麽用

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

[email protected]

@ResponseBody
@RequestMapping(method = RequestMethod.POST, value = "/testdate")
public String testdate(@RequestParam @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")Date birthday) {
System.out.println("a====a");
System.out.println(birthday);
return "aaa";
}

springmvc json轉對象時日期轉化