1

如何InvalidFormatException修复2019-12-01T06:16:50.289+0000

Caused by: com.fasterxml.jackson.databind.exc.InvalidFormatException: Cannot deserialize value of
type `org.threeten.bp.ZonedDateTime` from String "2019-12-01T06:16:50.289+0000": Failed to deserialize 
org.threeten.bp.ZonedDateTime: (org.threeten.bp.format.DateTimeParseException) 
Text '2019-12-01T06:16:50.289+0000'

对象映射器配置

  objectMapper.configure(JsonParser.Feature.ALLOW_UNQUOTED_FIELD_NAMES, true)
  objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false)
  objectMapper.enable(DeserializationFeature.UNWRAP_ROOT_VALUE)
  objectMapper.configure(DeserializationFeature.FAIL_ON_NULL_FOR_PRIMITIVES, false)
  objectMapper.configure(DeserializationFeature.ADJUST_DATES_TO_CONTEXT_TIME_ZONE, false)
  objectMapper.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS,false)

  objectMapper.registerModule(ThreeTenModule())

添加了以下依赖项

implementation 'com.tinder.scarlet:message-adapter-jackson:0.1.8'
implementation 'com.fasterxml.jackson.core:jackson-databind:2.10.0'
implementation 'com.fasterxml.jackson.core:jackson-core:2.10.0'
implementation 'com.fasterxml.jackson.core:jackson-annotations:2.10.0'
implementation 'com.fasterxml.jackson.jaxrs:jackson-jaxrs-json-provider:2.9.9'
implementation 'com.github.joschi.jackson:jackson-datatype-threetenbp:2.10.0'

implementation 'com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.9.4'
implementation 'javax.xml.bind:jaxb-api:2.3.0'
4

0 回答 0