I am using Spring Boot 2.1.8. I have imported
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-json</artifactId>
</dependency>
which includes the jackson-datatype-jsr310.
Then, I had to add these annotations
@JsonSerialize(using = LocalDateTimeSerializer.class)
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@JsonProperty("date")
LocalDateTime getDate();
and it works. The JSON looks like this:
"date": "2020-03-09 17:55:00"