Skip to content

[QUESTION] 发现有两种日期date格式不支持(12-hour clock 12小时制和CLDR) #2635

@qinbohan

Description

@qinbohan

String str1 = ""May 28, 2024 12:10:10 PM"";
System.out.println(com.alibaba.fastjson2.JSON.parseObject(str1, Date.class));
String str2 = ""Apr 2, 2024, 2:13:04 PM"";
System.out.println(com.alibaba.fastjson2.JSON.parseObject(str2, Date.class));

fastjson对这两种日期格式的反序列化好像都不支持。
第一个是12小时制的中午12点10分的表示方式,fastjson支持解析“May 28, 2024 00:10:10 PM”,无法解析“May 28, 2024 12:10:10 PM”但实际后者才是正确表达方式。
第二个是JDK9以后默认使用CLDR日期格式,与我们之前常用的相比,年份的后面多了个逗号,fastjson能解析“Apr 2, 2024 2:13:04 PM”,但无法解析“Apr 2, 2024, 2:13:04 PM”

Metadata

Metadata

Assignees

No one assigned

    Labels

    fixedquestionFurther information is requested

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions