Local java class
org.springframework.format.annotation.DateTimeFormat Import; Import java.time.LocalDateTime; / * ** * Problem record * / public class UserIssueProcessDto { / * ** * described process * / Private String f_clsm; / * ** * the construction team to handle * / Private String f_fk; / * ** * processing start time * / @DateTimeFormat (pattern = " yyyy-mM-dd HH: mm: SS " ) Private the LocalDateTime f_clkssj; / * ** * processing end time * / @DateTimeFormat (pattern = " YYYY the MM-dd-HH: mm: SS " ) Private the LocalDateTime f_cljssj; / * ** * long processing * / Private Double DURATION; Private String f_clry; Private String f_clryid; / * ** * Fill al ID * / Private Integer creatorId; / * ** * fill in the name of person * / Private String creatorName; / * ** * added * / Private the LocalDateTime f_addtime; public String getF_clsm () { return f_clsm; } public void setF_clsm(String f_clsm) { this.f_clsm = f_clsm; } public String getF_fk() { return f_fk; } public void setF_fk(String f_fk) { this.f_fk = f_fk; } public LocalDateTime getF_clkssj() { return f_clkssj; } public void setF_clkssj(LocalDateTime f_clkssj) { this.f_clkssj = f_clkssj; } public LocalDateTime getF_cljssj() { return f_cljssj; } public void setF_cljssj(LocalDateTime f_cljssj) { this.f_cljssj = f_cljssj; } public Double getDuration() { return duration; } public void setDuration(Double duration) { this.duration = duration; } public String getF_clry() { return f_clry; } public void setF_clry(String f_clry) { this.f_clry = f_clry; } public String getF_clryid() { return f_clryid; } public void setF_clryid(String f_clryid) { this.f_clryid = f_clryid; } public Integer getCreatorId() { return creatorId; } public void setCreatorId(Integer creatorId) { this.creatorId = creatorId; } public String getCreatorName() { return creatorName; } public void setCreatorName(String creatorName) { this.creatorName = creatorName; } public LocalDateTime getF_addtime() { return f_addtime; } public void setF_addtime(LocalDateTime f_addtime) { this.f_addtime = f_addtime; } }
Test code
String json = "[{\"f_clsm\":\"111\",\"f_fk\":\"-1\",\"f_clkssj\":\"2019-05-24 13:52:11\",\"f_cljssj\":\"2019-05-24 14:52:11\",\"f_clryid\":\"1000645\"}]"; List<UserIssueProcessDto> list = JSON.parseObject(json, new TypeReference<List<UserIssueProcessDto>>() {}); System.out.println(list);
Initially used in the project is found fastjson-1.2.7.jar
Given as follows:
com.alibaba.fastjson.JSONException: Text '2019-05-24 13:52:11' could not be parsed at index 10
at com.alibaba.fastjson.parser.DefaultJSONParser.parseObject(DefaultJSONParser.java:555)
at com.alibaba.fastjson.JSON.parseObject(JSON.java:251)
at com.alibaba.fastjson.JSON.parseObject(JSON.java:227)
at com.alibaba.fastjson.JSON.parseObject(JSON.java:181)
at com.TestSpringMVCConvert.test(TestSpringMVCConvert.java:19)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:45)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:42)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:263)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:68)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:47)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222)
at org.junit.runners.ParentRunner.run(ParentRunner.java:300)
at org.junit.runner.JUnitCore.run(JUnitCore.java:157)
at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68)
at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:47)
at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242)
at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)
Caused by: java.time.format.DateTimeParseException: Text '2019-05-24 13:52:11' could not be parsed at index 10
at java.time.format.DateTimeFormatter.parseResolved0(DateTimeFormatter.java:1949)
at java.time.format.DateTimeFormatter.parse(DateTimeFormatter.java:1851)
at java.time.LocalDateTime.parse(LocalDateTime.java:492)
at java.time.LocalDateTime.parse(LocalDateTime.java:477)
at com.alibaba.fastjson.parser.deserializer.Jdk8DateCodec.deserialze(Jdk8DateCodec.java:35)
at com.alibaba.fastjson.parser.deserializer.DefaultFieldDeserializer.parseField(DefaultFieldDeserializer.java:33)
at com.alibaba.fastjson.parser.deserializer.ASMJavaBeanDeserializer.parseField(ASMJavaBeanDeserializer.java:74)
at com.alibaba.fastjson.parser.deserializer.ASMJavaBeanDeserializer$InnerJavaBeanDeserializer.parseField(ASMJavaBeanDeserializer.java:86)
at com.alibaba.fastjson.parser.deserializer.JavaBeanDeserializer.deserialze(JavaBeanDeserializer.java:330)
at com.alibaba.fastjson.parser.deserializer.ASMJavaBeanDeserializer.parseRest(ASMJavaBeanDeserializer.java:100)
at Fastjson_ASM_UserIssueProcessDto_1.deserialze(Unknown Source)
at com.alibaba.fastjson.parser.DefaultJSONParser.parseArray(DefaultJSONParser.java:635)
at com.alibaba.fastjson.parser.deserializer.CollectionDeserializer.deserialze(CollectionDeserializer.java:63)
at com.alibaba.fastjson.parser.DefaultJSONParser.parseObject(DefaultJSONParser.java:551)
... 26 more
This problem was first discovered when springmvc entity attributes injection, modified various springmvc configuration is invalid.
Later, Lenovo recently used to mybatis use LocalDateTime / LocalDate and other classes use the class jsr310 time, the need to add additional jar package support.
Initially wrong to add in jackson-datatype-jsr310-2.7.0-rc1.jar, debugging has been ineffective.
Later found an article Fastjson support Java8 in LocalDateTime it? , Said fastjson-1.2.11 support, began to replace version.
From the author mvnrepository.com appropriate download version, after the final test, wenshao argument is wrong.
You must use fastjson-1.2.12 or later is required to resolve properly.
Original Address: https: //www.cnblogs.com/passedbylove/p/10930665.html
Local java class
org.springframework.format.annotation.DateTimeFormat Import; Import java.time.LocalDateTime; / * ** * Problem record * / public class UserIssueProcessDto { / * ** * described process * / Private String f_clsm; / * ** * the construction team to handle * / Private String f_fk; / * ** * processing start time * / @DateTimeFormat (pattern = " yyyy-mM-dd HH: mm: SS " ) Private the LocalDateTime f_clkssj; / * ** * processing end time * / @DateTimeFormat (pattern = " YYYY the MM-dd-HH: mm: SS " ) Private the LocalDateTime f_cljssj; / * ** * long processing * / Private Double DURATION; Private String f_clry; Private String f_clryid; / * ** * Fill al ID * / Private Integer creatorId; / * ** * fill in the name of person * / Private String creatorName; / * ** * added * / Private the LocalDateTime f_addtime; public String getF_clsm () { return f_clsm; } public void setF_clsm(String f_clsm) { this.f_clsm = f_clsm; } public String getF_fk() { return f_fk; } public void setF_fk(String f_fk) { this.f_fk = f_fk; } public LocalDateTime getF_clkssj() { return f_clkssj; } public void setF_clkssj(LocalDateTime f_clkssj) { this.f_clkssj = f_clkssj; } public LocalDateTime getF_cljssj() { return f_cljssj; } public void setF_cljssj(LocalDateTime f_cljssj) { this.f_cljssj = f_cljssj; } public Double getDuration() { return duration; } public void setDuration(Double duration) { this.duration = duration; } public String getF_clry() { return f_clry; } public void setF_clry(String f_clry) { this.f_clry = f_clry; } public String getF_clryid() { return f_clryid; } public void setF_clryid(String f_clryid) { this.f_clryid = f_clryid; } public Integer getCreatorId() { return creatorId; } public void setCreatorId(Integer creatorId) { this.creatorId = creatorId; } public String getCreatorName() { return creatorName; } public void setCreatorName(String creatorName) { this.creatorName = creatorName; } public LocalDateTime getF_addtime() { return f_addtime; } public void setF_addtime(LocalDateTime f_addtime) { this.f_addtime = f_addtime; } }
Test code
String json = "[{\"f_clsm\":\"111\",\"f_fk\":\"-1\",\"f_clkssj\":\"2019-05-24 13:52:11\",\"f_cljssj\":\"2019-05-24 14:52:11\",\"f_clryid\":\"1000645\"}]"; List<UserIssueProcessDto> list = JSON.parseObject(json, new TypeReference<List<UserIssueProcessDto>>() {}); System.out.println(list);
Initially used in the project is found fastjson-1.2.7.jar
Given as follows:
com.alibaba.fastjson.JSONException: Text '2019-05-24 13:52:11' could not be parsed at index 10
at com.alibaba.fastjson.parser.DefaultJSONParser.parseObject(DefaultJSONParser.java:555)
at com.alibaba.fastjson.JSON.parseObject(JSON.java:251)
at com.alibaba.fastjson.JSON.parseObject(JSON.java:227)
at com.alibaba.fastjson.JSON.parseObject(JSON.java:181)
at com.TestSpringMVCConvert.test(TestSpringMVCConvert.java:19)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:45)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:42)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:263)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:68)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:47)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222)
at org.junit.runners.ParentRunner.run(ParentRunner.java:300)
at org.junit.runner.JUnitCore.run(JUnitCore.java:157)
at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68)
at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:47)
at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242)
at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)
Caused by: java.time.format.DateTimeParseException: Text '2019-05-24 13:52:11' could not be parsed at index 10
at java.time.format.DateTimeFormatter.parseResolved0(DateTimeFormatter.java:1949)
at java.time.format.DateTimeFormatter.parse(DateTimeFormatter.java:1851)
at java.time.LocalDateTime.parse(LocalDateTime.java:492)
at java.time.LocalDateTime.parse(LocalDateTime.java:477)
at com.alibaba.fastjson.parser.deserializer.Jdk8DateCodec.deserialze(Jdk8DateCodec.java:35)
at com.alibaba.fastjson.parser.deserializer.DefaultFieldDeserializer.parseField(DefaultFieldDeserializer.java:33)
at com.alibaba.fastjson.parser.deserializer.ASMJavaBeanDeserializer.parseField(ASMJavaBeanDeserializer.java:74)
at com.alibaba.fastjson.parser.deserializer.ASMJavaBeanDeserializer$InnerJavaBeanDeserializer.parseField(ASMJavaBeanDeserializer.java:86)
at com.alibaba.fastjson.parser.deserializer.JavaBeanDeserializer.deserialze(JavaBeanDeserializer.java:330)
at com.alibaba.fastjson.parser.deserializer.ASMJavaBeanDeserializer.parseRest(ASMJavaBeanDeserializer.java:100)
at Fastjson_ASM_UserIssueProcessDto_1.deserialze(Unknown Source)
at com.alibaba.fastjson.parser.DefaultJSONParser.parseArray(DefaultJSONParser.java:635)
at com.alibaba.fastjson.parser.deserializer.CollectionDeserializer.deserialze(CollectionDeserializer.java:63)
at com.alibaba.fastjson.parser.DefaultJSONParser.parseObject(DefaultJSONParser.java:551)
... 26 more
This problem was first discovered when springmvc entity attributes injection, modified various springmvc configuration is invalid.
Later, Lenovo recently used to mybatis use LocalDateTime / LocalDate and other classes use the class jsr310 time, the need to add additional jar package support.
Initially wrong to add in jackson-datatype-jsr310-2.7.0-rc1.jar, debugging has been ineffective.
Later found an article Fastjson support Java8 in LocalDateTime it? , Said fastjson-1.2.11 support, began to replace version.
From the author mvnrepository.com appropriate download version, after the final test, wenshao argument is wrong.
You must use fastjson-1.2.12 or later is required to resolve properly.
Original Address: https: //www.cnblogs.com/passedbylove/p/10930665.html