-
Notifications
You must be signed in to change notification settings - Fork 6.5k
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
JSONObject.toJavaObject对于指定日期format解析报错 #3309
Comments
wenshao
added a commit
that referenced
this issue
Jun 30, 2020
Fix castToDate with format error #3309
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
public class Test {
public static void main(String[] args) {
}
class DateFormatTest {
@JSONField(format = "yyyyMMdd HH:mm:ss")
private Date formatDate;
运行程序报错
Exception in thread "main" com.alibaba.fastjson.JSONException: For input string: "20200623 15:20:01"
at com.alibaba.fastjson.util.TypeUtils.castToJavaBean(TypeUtils.java:1505)
at com.alibaba.fastjson.JSONObject.toJavaObject(JSONObject.java:603)
at Test .main(StartProvider.java:30)
Caused by: java.lang.NumberFormatException: For input string: "20200623 15:20:01"
at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)
at java.lang.Long.parseLong(Long.java:589)
at java.lang.Long.parseLong(Long.java:631)
at com.alibaba.fastjson.util.TypeUtils.castToDate(TypeUtils.java:482)
at com.alibaba.fastjson.parser.deserializer.JavaBeanDeserializer.createInstance(JavaBeanDeserializer.java:1435)
at com.alibaba.fastjson.util.TypeUtils.castToJavaBean(TypeUtils.java:1503)
但是这种写法是可以正常运行的,JSON.parseObject(jsonObj.toJSONString(), DateFormatTest.class);
之前升级到1.2.67是支持的,后来升级到1.2.72又不行了
The text was updated successfully, but these errors were encountered: