-
Notifications
You must be signed in to change notification settings - Fork 496
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] 序列化LocalDateTime字段时报错 #2206
Comments
LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ssXXX")) |
是新版本的不支持了吗,昨天从1点几版本升到2.0.45发现解析不了了 |
麻烦发下可以支持的版本号 |
com.alibaba fastjson 1.2.79 这个版本我试了是可以的 |
问题描述
简要描述您碰到的问题。
序列化
@jsonformat(
pattern = "yyyy-MM-dd'T'HH:mm:ssXXX",
timezone = "GMT+8"
)
private LocalDateTime birthday;
这样的字段时会出现以下错误
Exception in thread "main" com.alibaba.fastjson.JSONException: toJSONString error
at com.alibaba.fastjson.JSON.toJSONString(JSON.java:1498)
at com.yzy.portal.YfqTest.main(YfqTest.java:28)
Caused by: java.time.temporal.UnsupportedTemporalTypeException: Unsupported field: OffsetSeconds
at java.time.LocalDate.get0(LocalDate.java:680)
at java.time.LocalDate.getLong(LocalDate.java:659)
at java.time.LocalDateTime.getLong(LocalDateTime.java:720)
at java.time.format.DateTimePrintContext.getValue(DateTimePrintContext.java:298)
at java.time.format.DateTimeFormatterBuilder$OffsetIdPrinterParser.format(DateTimeFormatterBuilder.java:3346)
at java.time.format.DateTimeFormatterBuilder$CompositePrinterParser.format(DateTimeFormatterBuilder.java:2190)
at java.time.format.DateTimeFormatter.formatTo(DateTimeFormatter.java:1746)
at java.time.format.DateTimeFormatter.format(DateTimeFormatter.java:1720)
at com.alibaba.fastjson2.writer.ObjectWriterImplLocalDateTime.write(ObjectWriterImplLocalDateTime.java:121)
at com.alibaba.fastjson2.writer.FieldWriterObjectFinal.write(FieldWriterObjectFinal.java:83)
at com.alibaba.fastjson2.writer.ObjectWriter1.write(ObjectWriter1.java:68)
at com.alibaba.fastjson.JSON.toJSONString(JSON.java:1490)
... 1 more
Process finished with exit code 1
环境信息
请填写以下信息:
The text was updated successfully, but these errors were encountered: