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

ChoiceFormat returns erroneous result when formatting bad pattern

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P4 P4
    • 23
    • 8, 11, 23
    • core-libs
    • None
    • b12
    • generic
    • generic

      See the following code,

      var d = new ChoiceFormat("0#foo|1#bar|baz|")
      d.format(1) // unexpectedly returns ""

      It would have been preferable if either an exception was thrown when the ChoiceFormat was initially created, or the ChoiceFormat formatting 1 returned a value of bar.

      For comparison,
      var d = new ChoiceFormat("0#foo|1#bar|baz")
      d.format(1) // returns "bar"

            jlu Justin Lu
            jlu Justin Lu
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: