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

Instant.ofEpochMilli says it can throw an exception that it can't

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P4 P4
    • 21
    • None
    • core-libs
    • None
    • b21

      Instant.ofEpochMilli says this in its javadoc:

          * @throws DateTimeException if the instant exceeds the maximum or minimum instant

      But that can't actually happen:

      $ jshell
      | Welcome to JShell -- Version 21
      | For an introduction type: /help intro

      jshell> import java.time.Instant

      jshell> Instant.ofEpochMilli(Long.MAX_VALUE)
      $2 ==> +292278994-08-17T07:12:55.807Z

      jshell> Instant.ofEpochMilli(Long.MIN_VALUE)
      $3 ==> -292275055-05-16T16:47:04.192Z

            emcmanus Eamonn McManus
            emcmanus Eamonn McManus
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: