-
Enhancement
-
Resolution: Unresolved
-
P5
-
None
-
8, 9
-
generic
-
generic
A DESCRIPTION OF THE REQUEST :
java.sql.Timestamp.from(java.time.Instant) constructs a Timestamp from an Instant relative to the JVM timezone. If the JVM timezone is not UTC, the Timestamp value will differ from the Instant value.
This behavior is misleading. To rectify the situation I propose two changes:
1. Add a note in the Javadoc of this method mentioning the timezone conversion.
2. Add java.sql.Timestamp.from(java.time.Instant, java.time.ZoneOffset) which allows users to control the conversion. Specifically, Timestamp.from(Instant, ZoneOffset.UTC) would retain the original Instant value.
JUSTIFICATION :
JVMs running in a non-UTC timezone will experience unexpected results when invoking Timestamp.from(Instant). The Javadoc says nothing about a timezone conversion taking place.
java.sql.Timestamp.from(java.time.Instant) constructs a Timestamp from an Instant relative to the JVM timezone. If the JVM timezone is not UTC, the Timestamp value will differ from the Instant value.
This behavior is misleading. To rectify the situation I propose two changes:
1. Add a note in the Javadoc of this method mentioning the timezone conversion.
2. Add java.sql.Timestamp.from(java.time.Instant, java.time.ZoneOffset) which allows users to control the conversion. Specifically, Timestamp.from(Instant, ZoneOffset.UTC) would retain the original Instant value.
JUSTIFICATION :
JVMs running in a non-UTC timezone will experience unexpected results when invoking Timestamp.from(Instant). The Javadoc says nothing about a timezone conversion taking place.