gpt4 book ai didi

java - Spring无法反序列化请求参数日期 "Thu Dec 26 20:53:18 GMT+01:00 2019"

转载 作者:行者123 更新时间:2023-12-01 19:09:32 30 4
gpt4 key购买 nike

无法使用 @DateTimeFormat(pattern ="EEE MMM dd HH:mm:ss 'GMT'XXX yyyy") 解析“Thu Dec 26 20:53:18 GMT+01:00 2019” .

Failed to convert from type [java.lang.String] to type [@org.springframework.format.annotation.DateTimeFormat @org.springframework.web.bind.annotation.RequestParam java.util.Date] for value 'Thu Dec 26 20:53:18 GMT+01:00 2019'; nested exception is java.lang.IllegalArgumentException: Invalid format: "Thu Dec 26 20:53:18 GMT+01:00 2019" is malformed at "+01:00 2019"]

最佳答案

非常感谢@Deadpool和@Stephen C,结合你们的答案解决了我的问题。

public static final String DATE_TIME_FORMAT = "yyyy-MM-dd'T'HH:mm:ss.SSSXX";

public filter(@DateTimeFormat(pattern =DATE_TIME_FORMAT) LocalDate fromDate) {
...
}

我也更新了日期格式。

关于java - Spring无法反序列化请求参数日期 "Thu Dec 26 20:53:18 GMT+01:00 2019",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59493688/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com