I'm using JSON-B (yasson implementation) and I'm receiving data for an object with a field like this
{
...
"timestamp": "2020-03-19T06:42:42Z",
...
}
which is perfectly standard ISO 8601 for a UTC date-time value. Now the corresponding Java class simply declares a Date member variable with no other specific annotation
...
private Date timestamp;
...
everything seems to work fine and it looks like the JSON-B implementation correctly understands that as UTC without me having to specify a format using the @JsonbDateFormat annotation. I think I'm sure of it because I checked with
ZonedDateTime datetimeCheck = ZonedDateTime.of(2020, 3, 19, 6, 42, 42, 0, ZoneId.of("UTC"));
Date parsedDateFromJson = myModel.getTimestamp();
boolean compareTs = parsedDateFromJson.equals(Date.from(datetimeCheck.toInstant()));
and it yields true however, when I ran another test removing the 'Z' from the date-time value I was expecting it to produce a different result interpreting the date-time value as local rather than UTC. With my great surprise, the Date object obtained by JSON-B was exactly the same. What am I missing here? Why are 2020-03-19T06:42:42Z and 2020-03-19T06:42:42 the same thing? (I don't think they are). Or maybe is the JSON-B implementation considering UTC as default always when no timezone is specified?
Thanks