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

The Instant toString() method truncates the timestamp when milliseconds are 000

XMLWordPrintable

    • generic
    • generic

      ADDITIONAL SYSTEM INFORMATION :
      Java version running is 1.8.0_232

      A DESCRIPTION OF THE PROBLEM :
      When we have a date in the following format, 2021-04-16T16:42:15.003Z, the Instant class's toString method works as expected. However, when it is perfectly on a second (0ms) like this, 2021-04-16T16:42:15.000Z, then the toString method strips off the milliseconds and the returned date is rounded to the nearest second.
      i.e. 2021-04-16T16:42:15Z

      When passing in this timestamp as a RequestParameter to a controller function that accepts a @DateTimeFormat(iso = DATE_TIME) Date date, the milliseconds are required, therefore the truncation causes an exception.

      My proposal would be to keep the milliseconds in the stringified timestamp.



            Unassigned Unassigned
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: