Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG]Fastjson的时区反序列化 #1993

Closed
zacat opened this issue Nov 4, 2023 · 2 comments
Closed

[BUG]Fastjson的时区反序列化 #1993

zacat opened this issue Nov 4, 2023 · 2 comments
Labels
bug Something isn't working fixed
Milestone

Comments

@zacat
Copy link

zacat commented Nov 4, 2023

问题描述

时区反序列化不正常

环境信息

请填写以下信息:

  • OS信息: Windows 10
  • JDK信息: JDK17
  • 版本信息:Fastjson2 2.0.41

重现步骤

如何操作可以重现该问题:

    @Data
    public static class OrderDTO {
        LocalDate beginTime;
        LocalDate endTime;
    }

    public static void main(String[] args) {
        JSON.configReaderZoneId(ZoneId.of("Asia/Shanghai"));
        JSON.configWriterZoneId(ZoneId.of("Asia/Shanghai"));
        String str = "{\"beginTime\":\"2023-10-30T16:00:00.000Z\",\"endTime\":\"\"}";
        OrderQTO orderQTO = JSON.parseObject(str, OrderQTO.class);
        System.out.println(JSON.toJSONString(orderQTO));
    }

目前输出{"beginTime":"2023-10-30"}

期待的正确结果

{"beginTime":"2023-10-31"}

@zacat zacat added the bug Something isn't working label Nov 4, 2023
@zacat
Copy link
Author

zacat commented Nov 5, 2023

跟了代码,看到判定为UTC时区了,能再转回当前时区吗?

wenshao added a commit that referenced this issue Nov 5, 2023
@wenshao wenshao added this to the 2.0.42 milestone Nov 5, 2023
@wenshao wenshao added the fixed label Nov 5, 2023
@wenshao
Copy link
Member

wenshao commented Nov 5, 2023

https://oss.sonatype.org/content/repositories/snapshots/com/alibaba/fastjson/2.0.42-SNAPSHOT/
问题已修复,请帮忙用2.0.42-SNAPSHOT版本验证,正式版本预计今晚发布。

@zacat zacat closed this as completed Nov 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working fixed
Projects
None yet
Development

No branches or pull requests

2 participants