(fmt) incorrect example in Formatter javadoc

XMLWordPrintable

    • Type: Bug
    • Resolution: Fixed
    • Priority: P5
    • 8
    • Affects Version/s: 6, 7, 8
    • Component/s: core-libs
    • b115
    • Verified

      The last example before the "Organization" section in the class doc is incorrect. The example, with imports elided, is:

          Calendar c = new GregorianCalendar(1995, MAY, 23);
          String s = String.format("Duke's Birthday: %1$tm %1$te,%1$tY", c);
          // -> s == "Duke's Birthday: May 23, 1995"

      Instead, to match the output shown, it should probably be this:

          Calendar c = new GregorianCalendar(1995, MAY, 23);
          String s = String.format("Duke's Birthday: %1$tb %1$te, %1$tY", c);
          // -> s == "Duke's Birthday: May 23, 1995"

      That is, the %1$tm conversion should be %1$tb, and a space should be added after the comma.

      (Filed on behalf of joe.bowbeer@gmail.com)

            Assignee:
            Stuart Marks
            Reporter:
            Stuart Marks
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: