I am trying to do a Spring MVC RestController with kotlin, but I am having an hard time with RequestParams with LocalDatetime
@GetMapping
fun getParams(@RequestParam(required = true) endDate: LocalDateTime)
If I don't specify the param localhost:8080/
it gives an error that can be caught in a ControllerAdvice but if I specify a empty value localhost:8080/endDate=
it will give me
java.lang.IllegalArgumentException: Parameter specified as non-null is null: method net.agroop.deviceapi.controllers.DeviceController.getAirParams, parameter endDate
I found no way to catch that error in the ControllerAdvice because it is a kotlin error, I think.
I tried with other types like Date and it also gives error. If I use String it works because String can be empty. Also, if I specify LocalDateTime? as nullable it works but then I have to catch the error in the Controller in every RequestMapping and not in the ControllerAdvice.