如何在参数请求中接受将来的日期?

问题描述 投票:1回答:1

我希望控制器中的更新服务仅接受当前日期之后的日期,我尝试使用将来的注释,但是它不起作用...您能给我一个建议吗?特别是,我想如果用户输入日期1990-04-01T12:08:56Z,因为输入的日期不晚于当前日期,该服务将返回400,我认为@Future注释在这种意义上有效我错了,但仍然允许执行服务

@PatchMapping(path = "/{id}", produces = "application/json")
    public ResponseEntity<Employee> update(@PathVariable(value = "id") Integer id,
            @RequestParam(value = "afterdate") @Future @DateTimeFormat(pattern =" yyyy-MM-dd'T'HH:mm:ss'Z'")  Date afterdate) { .... 
java spring-boot rest hibernate-validator
1个回答
0
投票
© www.soinside.com 2019 - 2024. All rights reserved.