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

java.text.DecimalFormat.parse() fails when zeroDigit is not set to 0

XMLWordPrintable

    • sparc
    • solaris_2.5



      Name: dfC67450 Date: 11/27/97



      java.text.DecimalFormat.parse(String str, ParsePosition pp) parses
      wrong if zeroDigit field of DecimalFormatSymbols field is not set to 0.
       
      Here is the test demonstrating the bug:

      -----------------TestPZ.java------------------------
      import java.text.*;
      public class TestPZ {
          public static void main (String args[]){
              DecimalFormat df = new DecimalFormat();
              DecimalFormatSymbols dfs = df.getDecimalFormatSymbols();
              dfs.setZeroDigit('Z');
              df.setDecimalFormatSymbols(dfs);
              String str = "Z1";
              ParsePosition pp = new ParsePosition(0);
              System.out.println(str + " parses as " + df.parse(str, pp));
          }
      }
      ---------Output from the test---------------------
      Z1 parses as 0
      --------------------------------------------------

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

            joconnersunw John Oconner (Inactive)
            dfazunensunw Dmitri Fazunenko (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: