fastjson解析0000-00-00T00:00:00.000000000+08:00日期报错,怎么解决?

fastjson解析代码:

  String dateJson = "{\"date\":\"2019-05-21T15:42:45.814483302+08:00\"}";
//String dateJson = "{\"date\":\"2019-05-21T15:42:45.814+08:00\"}";
 Temp1 temp = JSONObject.parseObject(dateJson, Temp1.class);
 System.out.println(temp.date);

简单类结构:

class Temp1 {
      public Date date;
}

注释掉的那一行,fastjson是可以正常解析的,但是第一行json是无法解析成Date日期的,求大神解决办法!!!

以下是报错信息:

com.alibaba.fastjson.JSONException: For input string: "2019-05-21T15:42:45.814483302+08:00"

    at com.alibaba.fastjson.parser.DefaultJSONParser.parseObject(DefaultJSONParser.java:694)
    at com.alibaba.fastjson.JSON.parseObject(JSON.java:378)
    at com.alibaba.fastjson.JSON.parseObject(JSON.java:282)
    at com.alibaba.fastjson.JSON.parseObject(JSON.java:555)
    at ai.horizon.aiot.test.DeviceSpaceTest.updateDeviceSpaceTest(DeviceSpaceTest.java:67)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
    at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
    at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
    at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
    at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
    at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
    at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
    at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
    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.lang.NumberFormatException: For input string: "2019-05-21T15:42:45.814483302+08:00"
    at java.lang.NumberFormatException.forInputString(Unknown Source)
    at java.lang.Long.parseLong(Unknown Source)
    at java.lang.Long.parseLong(Unknown Source)
    at com.alibaba.fastjson.serializer.DateCodec.cast(DateCodec.java:270)
    at com.alibaba.fastjson.parser.deserializer.AbstractDateDeserializer.deserialze(AbstractDateDeserializer.java:177)
    at com.alibaba.fastjson.parser.deserializer.AbstractDateDeserializer.deserialze(AbstractDateDeserializer.java:15)
    at com.alibaba.fastjson.parser.deserializer.DefaultFieldDeserializer.parseField(DefaultFieldDeserializer.java:85)
    at com.alibaba.fastjson.parser.deserializer.JavaBeanDeserializer.parseField(JavaBeanDeserializer.java:1224)
    at com.alibaba.fastjson.parser.deserializer.JavaBeanDeserializer.deserialze(JavaBeanDeserializer.java:850)
    at com.alibaba.fastjson.parser.deserializer.JavaBeanDeserializer.deserialze(JavaBeanDeserializer.java:288)
    at com.alibaba.fastjson.parser.DefaultJSONParser.parseObject(DefaultJSONParser.java:687)
    ... 26 more
Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问

相似问题

4
fastjson反序列化List问题出现了
5
Log4j2启动报错,ava.lang.NoSuchMethodError
5
log4j升级到log4j2出现的问题,找不到log4j配置文件
8
mybatis中mapper配置问题
4
在过滤器里打印日志报如下错误(大概意思是请求不是同步的)怎么回事?
1
【急!】java访问hbase出错,无明显异常,无法读取对应表的信息(需求就是从Hbase之中的某张表读取信息)
1
springboot gradle mybatis MapperScan.factoryBean()异常
2
spring整合rabbitmq报错ListenerContainerFactoryBean初始化失败
0
用java完成json转换成csv中的问题:syntax error, expect [, actual error, pos 0, fieldName null
3
急!!!使用shiro+ssm时自定义Realm项目运行报错
1
用maven打了一个可运行jar,但是运行提示找不到类
4
利用阿里的fastjson.jar做java数组转化成json封装数据
0
The server encountered an unexpected condition that prevented it from fulfilling the request.
2
一开始自己配置的activiti的运行web时报错以为是环境的问题,后面到网上借鉴改了一些还是没用。
1
vue 传递json字符串数组给后台fastjson解析 但提示com.alibaba.fastjson.JSOnException:exepct '[' ,but {
1
springboot项目启动失败,求大神帮助
0
springboot集成apache.cxf实现wsdl webservice接口服务及客户端,使用maven打包是遇到乱码问题
4
使用fastjson中的TypeReference
3
有关SQL和JAVA中JSONArray的问题,有详细错误日志和sql语句图片
6
遇到一个 Bug,不会解决,有没有大佬来帮个忙!!!