I use Spring Boot and included jackson-datatype-jsr310
with Maven:
com.fasterxml.jackson.datatype
You did everything correct :) . Here is an example that shows exactly what you are doing. Just Annotate your RequestParam with @DateTimeFormat
. There is no need for special GenericConversionService
or manual conversion in the controller. This blog post writes about it.
@RestController
@RequestMapping("/api/datetime/")
final class DateTimeController {
@RequestMapping(value = "datetime", method = RequestMethod.POST)
public void processDateTime(@RequestParam("datetime")
@DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME) LocalDateTime dateAndTime) {
//Do stuff
}
}
I guess you had an issue with the format. On my setup everything works well.