We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
日期时间格式化注解,@JSONField(format = "xxx") 和 @JsonFormat(pattern = "xxx") 对 java.time.OffsetDateTime类型属性都失效。 属性类型改为 java.time.ZonedDateTime则生效。
@JSONField(format = "xxx")
@JsonFormat(pattern = "xxx")
java.time.OffsetDateTime
java.time.ZonedDateTime
定义Java Bean
@Getter @Setter public static class Item { private String jobNumber; /* 下列两种注解,对 updateTime 都失效,除非把 updateTime 改为 ZonedDateTime 类型 */ //@JSONField(format = "yyyy-MM-dd HH:mm") @JsonFormat(pattern = "yyyy-MM-dd HH:mm") private OffsetDateTime updateTime; }
调用 JSON.toJSONString(bean),永远以默认格式"yyyy-MM-dd'T'HH:mm:ss.SSSXXX输出
JSON.toJSONString(bean)
"yyyy-MM-dd'T'HH:mm:ss.SSSXXX
{"jobNumber":"ssss","updateTime":"2023-11-08T14:56:00.654744300+08:00"}
可以通过@JSONField(format = "")或@JsonFormat(pattern = "")指定日期序列化格式
@JSONField(format = "")
@JsonFormat(pattern = "")
The text was updated successfully, but these errors were encountered:
fix support OffsetDateTime format output for issue alibaba#2005
e534a16
fix support OffsetDateTime format output for issue #2005
44f37ef
https://oss.sonatype.org/content/repositories/snapshots/com/alibaba/fastjson2/fastjson2/2.0.43-SNAPSHOT/ 问题已修复,请帮忙用2.0.43-SNAPSHOT版本验证,2.0.43正式版本预计在12月3日前发布
Sorry, something went wrong.
要等大半个月~~??
最近发布的节奏是每个月初第一个周末发布新版本
https://github.com/alibaba/fastjson2/releases/tag/2.0.43 请用新版本
yanxutao89
No branches or pull requests
问题描述
日期时间格式化注解,
@JSONField(format = "xxx")
和@JsonFormat(pattern = "xxx")
对java.time.OffsetDateTime
类型属性都失效。属性类型改为
java.time.ZonedDateTime
则生效。环境信息
重现步骤
定义Java Bean
调用
JSON.toJSONString(bean)
,永远以默认格式"yyyy-MM-dd'T'HH:mm:ss.SSSXXX
输出期待的正确结果
可以通过
@JSONField(format = "")
或@JsonFormat(pattern = "")
指定日期序列化格式The text was updated successfully, but these errors were encountered: