public class CustomDeserializer extends JsonDeserializer<LocalDateTime> {
//兼容生长曲线纪录中前端可能会传递的recordTime格式为yyyy-MM-d HH:mm:ss的参数
public static final DateTimeFormatter format = DateTimeFormatter.ofPattern("yyyy-MM-d HH:mm:ss");
@Override
public LocalDateTime deserialize(JsonParser p, DeserializationContext ctxt) throws RuntimeException {
try{
if(p !=null && StringUtils.isNotEmpty(p.getText())){
return LocalDateTime.parse(p.getText(),format);
}else{
return null;
}
}catch (Exception e){
System.out.println(e.getMessage());
throw new RuntimeException();
}