Exception in thread "main" com.alibaba.fastjson.JSONException: For input string: "2019-01-25T17:34:13.1920977+08:00" at com.alibaba.fastjson.parser.DefaultJSONParser.parseObject(DefaultJSONParser.java:680) at com.alibaba.fastjson.JSON.parseObject(JSON.java:369) at com.alibaba.fastjson.JSON.parseObject(JSON.java:273) at com.alibaba.fastjson.JSON.parseObject(JSON.java:546) at work.darren.Test.main(Test.java:29) Caused by: java.lang.NumberFormatException: For input string: "2019-01-25T17:34:13.1920977+08:00"
Caused by: java.time.temporal.UnsupportedTemporalTypeException: Unsupported field: OffsetSeconds
at java.time.LocalDate.get0(LocalDate.java:680)
at java.time.LocalDate.getLong(LocalDate.java:659)
at java.time.LocalDateTime.getLong(LocalDateTime.java:720)
at java.time.format.DateTimePrintContext.getValue(DateTimePrintContext.java:298)
at java.time.format.DateTimeFormatterBuilder$OffsetIdPrinterParser.format(DateTimeFormatterBuilder.java:3335)
at java.time.format.DateTimeFormatterBuilder$CompositePrinterParser.format(DateTimeFormatterBuilder.java:2179)
at java.time.format.DateTimeFormatter.formatTo(DateTimeFormatter.java:1746)
at java.time.format.DateTimeFormatter.format(DateTimeFormatter.java:1720)
at com.alibaba.fastjson.parser.deserializer.Jdk8DateCodec.write(Jdk8DateCodec.java:484)
at com.alibaba.fastjson.parser.deserializer.Jdk8DateCodec.write(Jdk8DateCodec.java:467)
at com.alibaba.fastjson.serializer.FieldSerializer.writeValue(FieldSerializer.java:287)
at com.alibaba.fastjson.serializer.JavaBeanSerializer.write(JavaBeanSerializer.java:454)
... 6 more
7条答案
按热度按时间p5cysglq1#
9077913 这个值过大,不是毫秒数,这个是什么格式?
jexiocij2#
和第三方对接api时返回的时间格式,对方是用C#开发的。
目前的解决方法是使用LocalDateTime
但是这样也只能解析和S个数相同的时间
第三方返回的S长度又不固定,比较难解决
zbsbpyhn3#
我也遇到这个问题了,也是跟.net系统交互的时候,对方序列化过来的时间格式是:
"2019-01-25T17:34:13.1920977+08:00"
这边fastjson反序列化失败
zpqajqem4#
@wenshao jackson(2.9.8)可以正确解析,fastjson(1.2.56)无法解析
jackson:Fri Jan 25 17:34:13 CST 2019
Exception in thread "main" com.alibaba.fastjson.JSONException: For input string: "2019-01-25T17:34:13.1920977+08:00"
at com.alibaba.fastjson.parser.DefaultJSONParser.parseObject(DefaultJSONParser.java:680)
at com.alibaba.fastjson.JSON.parseObject(JSON.java:369)
at com.alibaba.fastjson.JSON.parseObject(JSON.java:273)
at com.alibaba.fastjson.JSON.parseObject(JSON.java:546)
at work.darren.Test.main(Test.java:29)
Caused by: java.lang.NumberFormatException: For input string: "2019-01-25T17:34:13.1920977+08:00"
nkhmeac65#
最新版本 1.2.59,已经解决。
o2g1uqev6#
1.2.59
报错
@Omega-Ariston
jv4diomz7#
这是因为
java.time.LocalDateTime
不支持时区偏移量, 也就是+08:00
. 建议使用java.time.OffsetDateTime
@CielDai