Connected to the target VM, address: '127.0.0.1:58990', transport: 'socket'
Exception in thread "main" com.alibaba.fastjson2.JSONException: can not cast to java.time.LocalDateTime, from class java.lang.Integer
at com.alibaba.fastjson2.util.TypeUtils.cast(TypeUtils.java:1521)
at com.alibaba.fastjson2.reader.FieldReader.acceptAny(FieldReader.java:429)
at com.alibaba.fastjson2.reader.ObjectReaderAdapter.createInstance(ObjectReaderAdapter.java:627)
at com.alibaba.fastjson2.JSONObject.to(JSONObject.java:1248)
at com.alibaba.fastjson2.JSONObject.toJavaObject(JSONObject.java:1258)
at net.gaox.util.date.json.deserializer.test.T2.main(T2.java:18)
Disconnected from the target VM, address: '127.0.0.1:58990', transport: 'socket'
Process finished with exit code 1
期待的正确结果(fastjson的结果)
Connected to the target VM, address: '127.0.0.1:58981', transport: 'socket'
1970-01-01T08:00
2020-01-01T08:00
Disconnected from the target VM, address: '127.0.0.1:58981', transport: 'socket'
Process finished with exit code 0
问题描述
使用fastjson2解析1970年的时间时,报错
can not cast to java.time.LocalDateTime, from class java.lang.Integer
。但是fastjson不会环境信息
请填写以下信息:
重现步骤
import com.alibaba.fastjson2.JSONObject
改为import com.alibaba.fastjson.JSONObject;
测试代码
异常的结果(fastjson2的结果)
期待的正确结果(fastjson的结果)