SqlTypes.TIMESTAMP_UTC to model UTC stored timestamp for java.time.Instant #4463
Replies: 2 comments 2 replies
-
That sounds like a very good suggestion to me. |
Beta Was this translation helpful? Give feedback.
1 reply
-
IIRC there are. They interpret |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Create a
SqlTypes
constant forTIMESTAMP_UTC
which will map totimestamptz
on PostgreSQL/CockroachDB andtimestamp
on MySQL/MariaDB which store no zone offset, but instead normalizes to UTC. This type can be used as recommended JDBC type forjava.time.Instant
and for theTimeZoneStorageType.NORMALIZE
strategy.Currently, when binding/extracting a value for this type, we go through a
java.sql.Timestamp
instance which drivers seem to normalize to the system timezone. We could improve the situation here by requesting normalization to UTC. Another advantage of this type is that we can register aJdbcType
implementation for JDBC drivers that support it, which avoids wrappingInstant
into ajava.sql.Timestamp
and pass theInstant
directly instead.I didn't research much yet, but maybe other databases also support some kind of DDL type that also does UTC normalization, which this new constant would allow us to make use of.
Beta Was this translation helpful? Give feedback.
All reactions