Open oarkhipov opened 3 years ago
Seems the solution is not yet made.
I think that I may have run into this one too.
Take for example the json,
"appointment_start_date_time_utc": "2022-04-01T15:00:00",
I then define the json schema as,
"appointment_start_date_time_utc": {
"customDateTimePattern" : "yyyy-MM-dd'T'HH:mm:ss",
"customTimezone": "UTC",
"format" : "date-time",
"type": "string"
},
That produces the java object with
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss", timezone = "UTC")
@JsonProperty("appointment_start_date_time_utc")
private OffsetDateTime appointmentStartDateTimeUtc;
Unfortunately it fails with the error below.
The formatter parses it to a java.time.format.Parsed
with the value
{InstantSeconds=1648825200},ISO,UTC resolved to 2022-04-01T15:00
Jackson calls OffsetDateTime.from(temporal)
which fails by not knowing the ZoneOffset. This should have been UTC, so I'm not sure why that was lost.
Using customDateTimePattern=yyyy-MM-dd'T'HH:mm:ss.SSSXXX and dateTimeType=java.time.Instant give us: @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss.SSSXXX", timezone = "UTC") That's incorrect The string 2020-12-09T14:09:35.573+03:00 becomes an Instant of 2020-12-09T14:09:35.573Z (actual time zone ignored) After removing timezone=UTC all work perfectly.
We need an option to explicit define default timeZone.
Now there is no way to get rid of timezone = "UTC" without modifying source json-schema. As workaround, i use customTimeZone="##default" in schema.. that works too. But that's not always possible to modify source schema.
Regards, Oleg