본문 바로가기
Spring/boot

spring boot localDateTime parsing

by 무대포 개발자 2020. 9. 11.
728x90
반응형

rest api request localDateTime parsing

  • rest api 를 통해 들어온 request param 의 localDateTime type 을 파싱
  • controller 의 /test url 을 통해 request 가 json 타입으로 들어오면 파싱 가능
    public class SampleIO {
      @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
      private LocalDateTime dateTime;
    
    

@RequestMapping(value = "/test", method = RequestMethod.POST)
public ResponseEntity<?> testParsing(@RequestBody SampleIO sampleIO) {
xxx
xxx
xxx
}



```json
{
  "dateTime": "2020-08-24T11:25:00"
}

refernece

댓글