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

Format objects can't always parse their own output

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P4 P4
    • 1.4.0
    • 1.2.0
    • core-libs
    • beta2
    • generic
    • generic



      Name: vi73552 Date: 04/08/99


      class MessageFormatBug {
      public static void main(String[] args)
      {
      // example of correct behavior
      java.text.MessageFormat msgfmt1 = new java.text.MessageFormat("{0,number,0}X{1,number,00}");
      Object[] args1 = {new Integer(1),new Integer(0)};
      String s1 = msgfmt1.format(args1);
      System.out.println(s1);
      try
      {
      msgfmt1.parse(s1);
      }
      catch (Exception e1)
      {
      System.out.println(e1);
      }

      // example with ajacent fields
      java.text.MessageFormat msgfmt2 = new java.text.MessageFormat("{0,number,0}{1,number,00}");
      Object[] args2 = {new Integer(1),new Integer(0)};
      String s2 = msgfmt2.format(args2);
      System.out.println(s2);
      try
      {
      msgfmt2.parse(s2);
      }
      catch (Exception e2)
      {
      System.out.println(e2);
      }
      }
      }
      //////////////////////////////////////////////////////////////
      Out:
      C:\dev>java MessageFormatBug
      1X00
      100
      java.text.ParseException: MessageFormat parse error!

      //////////////////////////////////////////////////////////////
      VersionInfo:
      C:\dev>java -version
      java version "1.2"
      Classic VM (build JDK-1.2-V, native threads)

      C:\dev>java -fullversion
      java full version "JDK-1.2-V"
      (Review ID: 56709)
      ======================================================================

            nlindenbsunw Norbert Lindenberg (Inactive)
            vasya Vassili Igouchkine (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: