为什么我无法反序列化“Wed Mar 09 14:02:57 +0800 2022”格式为“EEE MMM dd HH:mm:ss Z yyyy”?

发布于 2025-01-15 07:30:13 字数 408 浏览 4 评论 0原文

为什么我无法使用 EEE MMM dd HH:mm:ss Z yyyy 反序列化 Wed Mar 09 14:02:57 +0800 2022?有什么问题吗?

我正在使用 Jackson,并在实体类中添加了此注释

@JsonFormat(pattern="EEE MMM dd HH:mm:ss Z yyyy")
private Date created_at;

但是,我收到此错误:

无法从字符串“Wed Mar 反序列化 java.util.Date 类型的值 09 14:02:57 +0800 2022”:预期格式“EEE MMM dd HH:mm:ss Z yyyy”

Why can't I use EEE MMM dd HH:mm:ss Z yyyy to deserialize Wed Mar 09 14:02:57 +0800 2022? Is there anything wrong?

I am using Jackson and I added this annotation in my entity class

@JsonFormat(pattern="EEE MMM dd HH:mm:ss Z yyyy")
private Date created_at;

However, I got this error:

Cannot deserialize value of type java.util.Date from String "Wed Mar
09 14:02:57 +0800 2022": expected format "EEE MMM dd HH:mm:ss Z yyyy"

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

勿忘初心 2025-01-22 07:30:13

我建议摆脱该格式并使用 ISO 8601 代替。

另外,最好使用 中的类java.time 包。

I recommend to escape from that format and use ISO 8601 instead.

Also, it's better to use the classes in the java.time package.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文