I'm testing how timestamps are stored into Oracle DB using JPA and I'm a little surprised by the result.
The oracle docs:
https://docs.oracle.com/cd/B19306_01/server.102/b14225/ch4datetime.htm
explains, that timestamp should be stored along with timestamp.
On input I have this timestamp: 2021-01-07T15:30:06.540+05:00
. Application server runs in -09:00 timezone. DB server runs in +01:00. When I store into TIMESTAMP WITH TIME ZONE
column, I'd expect, that timestamp with "+05:00" will be stored into db, the timezone of timestamp, but it is -09:00, the timezone of app server.
the field in entity is mapped as:
@Column(name = "g", nullable = false)
private OffsetDateTime g_parsedAsOffsetDateTimeStoredAsWithTimeZone;
and it's value is parsed from input string as
OffsetDateTime.parse(input.getA(), ISO_ZONED_DATE_TIME)
I don't think that -09:00
I see in DB is based on some interpretation of timestamp by application I use to read db with, because actually I don't live in alaska and alaska timezone was just selected as an extreme to run app server with to make sure I don't see any "correct" value by mistake.
What is to be expected when storing OffsetDateTime as such? Timezone from request or timezone of application server? Why am I seing the timezone of app server, it does not seem to make sense.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…