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] 输入错误的日期字符串时调用JSONObject.getDate方法输出超出预期 #912

Closed
BABYSHARPYIN opened this issue Nov 9, 2022 · 2 comments
Labels
bug Something isn't working fixed
Milestone

Comments

@BABYSHARPYIN
Copy link

问题描述

简要描述您碰到的问题。
在输入错误的日期字符串时输出超出预期

环境信息

请填写以下信息:

  • OS信息: [macOS 12.6 (21G115)]
  • JDK信息: [jdk1.8.0_291]
  • 版本信息:[Fastjson2 2.0.18]

重现步骤

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

  1. 使用 JSONObject.getDate 方法
  2. 输入 "2000-00-00 00:00:00" 数据
  3. 出现 Wed Dec 01 00:00:00 CST 1999 错误,该输出不符合预期
try {
            String time = "2000-00-00 00:00:00";
            com.alibaba.fastjson2.JSONObject jsonObject = new com.alibaba.fastjson2.JSONObject();
            jsonObject.put("time", time);
            System.out.println(jsonObject.getDate("time"));
            System.out.println(System.getenv());
        } catch (Exception e) {
            e.printStackTrace();
        }

期待的正确结果

对您期望发生的结果进行清晰简洁的描述。
如果输入一个错误的时间格式,是否应该抛出异常由用户处理

相关日志输出

请复制并粘贴任何相关的日志输出。

附加信息

DateUtiles 中 toMillis19 方法认为月份大于 12 或日期大于 32 .... 也是合法的
image

@BABYSHARPYIN BABYSHARPYIN added the bug Something isn't working label Nov 9, 2022
@BABYSHARPYIN BABYSHARPYIN changed the title [BUG] [BUG] 输入错误的日期字符串时调用JSONObject.getDate方法输出超出预期 Nov 9, 2022
wenshao added a commit that referenced this issue Nov 9, 2022
@wenshao wenshao added this to the 2.0.19 milestone Nov 10, 2022
@wenshao wenshao added the fixed label Nov 10, 2022
@wenshao
Copy link
Member

wenshao commented Nov 11, 2022

https://oss.sonatype.org/content/repositories/snapshots/com/alibaba/fastjson2/fastjson2/2.0.19-SNAPSHOT/
问题已修复,请帮忙用2.0.19-SNAPSHOT验证,2.0.19版本预计在11月13日前发布。

@wenshao
Copy link
Member

wenshao commented Nov 12, 2022

https://github.com/alibaba/fastjson2/releases/tag/2.0.19
请用新版本

@wenshao wenshao closed this as completed Nov 12, 2022
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