Skip to content
This repository has been archived by the owner on Oct 23, 2024. It is now read-only.

带时区日期反序列化bug #4407

Open
wsjfly opened this issue Jun 6, 2023 · 2 comments
Open

带时区日期反序列化bug #4407

wsjfly opened this issue Jun 6, 2023 · 2 comments

Comments

@wsjfly
Copy link

wsjfly commented Jun 6, 2023

测试类:
public static final String TIMEZONE_FORMAT = "yyyy-MM-dd'T'HH:mm:ssXXX";
public class ShipmentPlanVO {

private String id;
@JSONField(name = "from", format = DateUtils.TIMEZONE_FORMAT)
private Date from;

....
}

main方法主要部分
String str2 = "{"id":1480666,"from":"2023-06-05T20:31:00-06:00"}";
JSONObject p1 = JSON.parseObject(str2);
ShipmentPlanVO p2 = p1 .toJavaObject(ShipmentPlanVO.class);
System.out.println(JSON.toJSONString(p2));
实际输出:{"from":"2023-06-06T09:31:00+08:00","id":"1480666"}
正确的时间from应该是: 2023-06-06T10:31:00+08:00, 实际输出早了1个小时

@wsjfly
Copy link
Author

wsjfly commented Jun 7, 2023

版本:1.2.65

@wenshao
Copy link
Member

wenshao commented Jun 20, 2023

用2.0.34试试看

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants