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

Missing @throws in DateTimeFormatterBuilder.appendInstant

XMLWordPrintable

    • b50

        The method DateTimeFormatterBuilder.appendInstant(int) can throw an exception that is not properly specified. The current spec implies an exception by defining the accepted values as follows: "Specifying zero will cause no fractional digits to be output. From 1 to 9 will output an increasing number of digits, using zero right-padding if necessary. The special value -1 is used to output as many digits as necessary to avoid any trailing zeroes.", however there is no @throws clause. Use of IllegalArgumentException is implied from other similar methods on the class.

        Fix proposed as follows:

             * @param fractionalDigits the number of fractional second digits to format with,
             * from 0 to 9, or -1 to use as many digits as necessary
             * @return this, for chaining, not null
             * @throws IllegalArgumentException if the number of fractional digits is invalid
             */
            public DateTimeFormatterBuilder appendInstant(int fractionalDigits) {

        (around line 854)

        While fixing this issue, the leap second time should be fixed in the Javadoc of the same method. It is currently "23:59:59" but it should be "23:59:60". (The leap second time is a known fact, thus the Javadoc is simply wrong, and this is not a spec change).

              rriggs Roger Riggs
              scolebourne Stephen Colebourne
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

                Created:
                Updated:
                Resolved: