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

(fmt spec) Formatter's javadoc has a wrong example for '%<' argument index

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P4 P4
    • 6
    • 5.0
    • core-libs
    • b23
    • generic, x86
    • solaris_8, windows_xp

      A DESCRIPTION OF THE PROBLEM :
      Right before "Details" part of format string explanation, the original text writes:

      Another way to reference arguments by position is to use the '<' ('\u003c') flag, which causes the argument for the previous format specifier to be re-used. For example, the following two statements would produce identical strings:

         Calendar c = ...;
         String s1 = String.format("Duke's Birthday: %1$tm %1$te,%1$tY", c);

         String s2 = String.format("Duke's Birthday: %1$tm %<$te,%<$tY", c);

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      The last line uses

      "%<$..."

       for last argument reuse, which should be

      "%<..."

      URL OF FAULTY DOCUMENTATION :
      http://java.sun.com/j2se/1.5.0/docs/api/java/util/Formatter.html
      ###@###.### 2004-12-22 18:43:48 GMT

            iris Iris Clark
            rmandalasunw Ranjith Mandala (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: