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

java.text.DecimalFormat.parse incorrectly works with a group separator

    XMLWordPrintable

    Details

    • Subcomponent:
    • Resolved In Build:
      1.2beta4
    • CPU:
      sparc
    • OS:
      solaris_2.5
    • Verification:
      Verified

      Description



      Name: dfC67450 Date: 02/02/98



      java.text.DecimalFormat.parse(String text, ParsePosition pp) incorrectly parses
      numbers when group separator is after decimal separator.
       
      Here is the test demonstrating the bug:

      -----------------Test.java------------------------
      import java.text.*;

      public class Test {
          public static void main (String args[]){
              DecimalFormat df = new DecimalFormat("#,##0.###", new DecimalFormatSymbols(java.util.Locale.US));
              String text = "1.222,111";
              System.out.println("\"" + text + "\" is parsed as " +
                      df.parse(text,new ParsePosition(0)));
              text = "1.222x111";
              System.out.println("\"" + text + "\" is parsed as " +
                      df.parse(text,new ParsePosition(0)));
          }
      }

      ---------Output from the test---------------------
      "1.222,111" is parsed as 1.222111
      "1.222x111" is parsed as 1.222
      --------------------------------------------------

      ======================================================================

        Attachments

          Activity

            People

            Assignee:
            duke J. Duke (Inactive)
            Reporter:
            dfazunensunw Dmitri Fazunenko (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: