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] yyyyMMddHHmmssSSS格式字符串转LocalDateTime失败 #1065

Closed
Ryoui opened this issue Jan 10, 2023 · 4 comments
Closed

[BUG] yyyyMMddHHmmssSSS格式字符串转LocalDateTime失败 #1065

Ryoui opened this issue Jan 10, 2023 · 4 comments
Labels
bug Something isn't working fixed
Milestone

Comments

@Ryoui
Copy link

Ryoui commented Jan 10, 2023

问题描述

yyyyMMddHHmmssSSS格式字符串转LocalDateTime失败,有横线的格式能成功,但fastjson1两种格式都可以

环境信息

请填写以下信息:

  • OS信息: [e.g.:windows 11]
  • JDK信息: [e.g.:jdk 1.8.0_201]
  • 版本信息:[e.g.:Fastjson2 2.0.22]

重现步骤

执行下面代码可重现

public class Fastjson2Test {

    @Test
    public void test(){
        // yyyyMMddHHmmssSSS
        String data = "{\"date\":\"2022-08-12\",\"createTime\":\"20220812214301538\"}";
        //String data = "{\"date\":\"2022-08-12\",\"createTime\":\"2022-08-12 21:43:01.538\"}";
        DateTime dateTime = JSONObject.parseObject(data, DateTime.class);
        System.out.println(dateTime.toString());
    }

    public static class DateTime{
        private LocalDate date;
        private LocalDateTime createTime;

        @Override
        public String toString() {
            return "DateTime{" +
                    "date=" + date +
                    ", createTime=" + createTime +
                    '}';
        }

        public LocalDate getDate() {
            return date;
        }

        public void setDate(LocalDate date) {
            this.date = date;
        }

        public LocalDateTime getCreateTime() {
            return createTime;
        }

        public void setCreateTime(LocalDateTime createTime) {
            this.createTime = createTime;
        }
    }
}

期待的正确结果

都支持

@Ryoui Ryoui added the bug Something isn't working label Jan 10, 2023
@wenshao
Copy link
Member

wenshao commented Jan 10, 2023

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

@wenshao wenshao added the fixed label Jan 10, 2023
@wenshao wenshao added this to the 2.0.23 milestone Jan 10, 2023
@Ryoui
Copy link
Author

Ryoui commented Jan 11, 2023

@wenshao 2.0.23-SNAPSHOT版经测试已修复,待正式发版后再次确认下。

@wenshao
Copy link
Member

wenshao commented Jan 14, 2023

https://github.com/alibaba/fastjson2/releases/tag/2.0.23
问题已经修复,请用新版本

@wenshao wenshao closed this as completed Jan 14, 2023
@Ryoui
Copy link
Author

Ryoui commented Jan 16, 2023

thx,good job

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