Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8169564

Add Timestamp.from(Instant, ZoneOffset)

XMLWordPrintable

    • 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.


            lancea Lance Andersen
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: