输入json有效载荷如下所示。我的实体类ImportTrans eventTime类型目前是LocalDate。如何格式化它以接受json输入格式。
{
"eventId":"ep9_0579af51-4b5c",
"eventTime":"5/11/2022 5:50:58 PM",
"eventType":"Update"
}
public class ImportTrans implements Serializable {
@Id
private Long processId;// AutoGenerator
private String eventId;
private LocalDate eventTime;
private String eventType;
}HttpMessageNotReadableException坏请求400错误- JSON解析错误:无法从字符串"5/11/2022 5:50:58 PM“反序列化java.time.LocalDate类型的值:
发布于 2022-05-11 21:02:59
基于您的春季引导版本,如果它的>=2.2,那么下面可能会立即工作。
import com.fasterxml.jackson.annotation.JsonFormat;
..
@JsonFormat(pattern = "dd/MM/yyyy HH:mm:ss")
private LocalDate eventTime;https://stackoverflow.com/questions/72207239
复制相似问题