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] #413

Closed
dance3366 opened this issue Jun 6, 2022 · 3 comments
Closed

[BUG] #413

dance3366 opened this issue Jun 6, 2022 · 3 comments
Labels
bug Something isn't working
Milestone

Comments

@dance3366
Copy link

问题描述

反序列unixtime时间字符串到java.util.Date报错

环境信息

  • JDK信息: Openjdk 1.8.0_312
  • 版本信息:Fastjson2 0.6

重现步骤

  1. 使用 JSON.parseObject 方法
  2. 出现 Exception in thread "main" java.lang.IllegalArgumentException: Unknown pattern letter: i 错误
String date1 = JSONObject.of("date1", "1654134285").toString();
Date date = JSON.parseObject(date1, Test.class).getDate1();

@Data
class Test{
    @JSONField(format = "unixtime")
    private Date date1;
}

期待的正确结果

反序列化成功

相关日志输出

Exception in thread "main" java.lang.IllegalArgumentException: Unknown pattern letter: i
at java.time.format.DateTimeFormatterBuilder.parsePattern(DateTimeFormatterBuilder.java:1672)
at java.time.format.DateTimeFormatterBuilder.appendPattern(DateTimeFormatterBuilder.java:1581)
at java.time.format.DateTimeFormatter.ofPattern(DateTimeFormatter.java:536)
at com.alibaba.fastjson2.reader.FieldReaderDateMethod.getFormatter(FieldReaderDateMethod.java:117)
at com.alibaba.fastjson2.reader.FieldReaderDateMethod.readFieldValue(FieldReaderDateMethod.java:76)
at com.alibaba.fastjson2.reader.ObjectReader1.readObject(ObjectReader1.java:242)
at com.alibaba.fastjson2.JSON.parseObject(JSON.java:421)
at com.example.jdbc.UnixTimeTest.main(UnixTimeTest.java:22)

@dance3366 dance3366 added the bug Something isn't working label Jun 6, 2022
@wenshao wenshao added this to the 2.0.7 milestone Jun 6, 2022
@wenshao
Copy link
Member

wenshao commented Jun 6, 2022

https://oss.sonatype.org/content/repositories/snapshots/com/alibaba/fastjson2/fastjson2/2.0.7-SNAPSHOT/

问题已经修复,你用2.0.7-SNAPSHOT先验证一下

@dance3366
Copy link
Author

dance3366 commented Jun 7, 2022

https://oss.sonatype.org/content/repositories/snapshots/com/alibaba/fastjson2/fastjson2/2.0.7-SNAPSHOT/

问题已经修复,你用2.0.7-SNAPSHOT先验证一下

maven的settings文件配置可以发一下,我配置如下,依赖一直下载不成功

	 <mirror>
		<id>nexus-snapshots</id>
		<mirrorOf>Snapshots</mirrorOf>
		<name>Nexus snapshots</name>
		<url> https://oss.sonatype.org/content/repositories/snapshots/</url>
	 </mirror>

@wenshao
Copy link
Member

wenshao commented Jun 11, 2022

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

@wenshao wenshao closed this as completed Jun 11, 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
Projects
None yet
Development

No branches or pull requests

2 participants