Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-8084463 | emb-9 | Roger Riggs | P4 | Resolved | Fixed | team |
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).
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).
- backported by
-
JDK-8084463 Missing @throws in DateTimeFormatterBuilder.appendInstant
-
- Resolved
-