为什么我无法反序列化“Wed Mar 09 14:02:57 +0800 2022”格式为“EEE MMM dd HH:mm:ss Z yyyy”?
为什么我无法使用 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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我建议摆脱该格式并使用 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.