spring mvc 默认用的是 jackson 来解析 json 的,所以 Date 的解析得下面这么用

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

 

如果是@RequestParam则用这种方式:

    @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";
    }

相关文章:

  • 2021-10-17
  • 2022-12-23
  • 2021-11-30
  • 2022-12-23
  • 2022-12-23
  • 2021-12-22
  • 2021-12-22
  • 2022-02-03
猜你喜欢
  • 2022-01-10
  • 2022-02-07
  • 2021-12-22
  • 2022-02-15
  • 2021-12-14
  • 2021-11-18
  • 2021-08-15
相关资源
相似解决方案