-
Notifications
You must be signed in to change notification settings - Fork 479
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]对象转JsonString后,时间发生变化 #2650
Labels
bug
Something isn't working
Comments
对于1900-1-1的时区,java.time和SimpleDateFormat的处理方式不一样。fastjson2使用的是java.time API。 String dateStr = "1900-01-01 00:06:43.0";
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.S");
Date date = simpleDateFormat.parse(dateStr);
System.out.println(date);
System.out.println(date.toInstant().atZone(ZoneId.of("Asia/Shanghai")));
System.out.println(JSON.toJSONString(date, SerializerFeature.WriteDateUseDateFormat)); System.out.println(date.toInstant().atZone(ZoneId.of("Asia/Shanghai"))); 打印的结果就是fastjson2的结果 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
问题描述
简要描述您碰到的问题。
fastjson版本从1.2.83升级到2.0.49之后,日期转为jsonString时,日期发生改变
环境信息
请填写以下信息:
重现步骤
如何操作可以重现该问题:
相关日志输出
请复制并粘贴任何相关的日志输出。
打印结果如下:
The text was updated successfully, but these errors were encountered: