0

I have a class Dto that will set a value with LocalDateTime as Data Type.

I get an error when receiving a JSON.

public class Dto {

@JsonFormat(shape = JsonFormat.Shape.STRING)
    private LocalDateTime scheduledStartTime;

}
}

Here is the error:

Cannot construct instance of `java.time.LocalDateTime` (no Creators, like default construct, exist): no String-argument constructor/factory method to deserialize from String value ('2019-08-01T15:30:00Z')
mengmeng
  • 1,266
  • 2
  • 22
  • 46

1 Answers1

0

try disabling :

objectMapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS)

or

@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@JsonSerialize(using = LocalDateTimeSerializer.class)