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

Clarify how DateTimeFormatterBuilder.appendFraction handles value ranges

    XMLWordPrintable

Details

    • CSR
    • Status: Closed
    • P4
    • Resolution: Approved
    • 18
    • core-libs
    • None
    • behavioral
    • minimal
    • Clarifies existing behavior in the OpenJDK implementation. It's very unlikely other java.time implementations exist.
    • Java API
    • SE

    Description

      Summary

      Improve the specification of DateTimeFormatterBuilder.appendFraction to more clearly state that an exception will be thrown if the value to be printed is outside of the field's value range.

      Problem

      Current specification is ambiguous on what constitutes an invalid value.

      Solution

      Clarify the specification.

      Specification

      Adjust the javadoc for DateTimeFormatterBuilder.appendFraction like so:

      diff --git a/src/java.base/share/classes/java/time/format/DateTimeFormatterBuilder.java b/src/java.base/share/classes/java/time/format/DateTimeFormatterBuilder.java
      index 50c4155c4ac..7af964f106b 100644
      --- a/src/java.base/share/classes/java/time/format/DateTimeFormatterBuilder.java
      +++ b/src/java.base/share/classes/java/time/format/DateTimeFormatterBuilder.java
      @@ -688,8 +688,8 @@ public final class DateTimeFormatterBuilder {
            * If the value is negative an exception will be thrown.
            * If the field does not have a fixed set of valid values then an
            * exception will be thrown.
      -     * If the field value in the date-time to be printed is invalid it
      -     * cannot be printed and an exception will be thrown.
      +     * If the field value in the date-time to be printed is outside the
      +     * range of valid values then an exception will be thrown.
            *
            * @param field  the field to append, not null
            * @param minWidth  the minimum width of the field excluding the decimal point, from 0 to 9

      Attachments

        Issue Links

          Activity

            People

              redestad Claes Redestad
              redestad Claes Redestad
              Roger Riggs
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: