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

java.text.DecimalFormat.format() incorrectly formats 0.0

XMLWordPrintable

    • 1.1.6
    • sparc
    • solaris_2.5
    • Verified



        Name: dfC67450 Date: 10/21/97



        java.text.DecimalFormat.format(double, StringBuffer, FieldPosition) formats 0.0
        as the empty string when MinimumIntegerDigits setting is 0.
         
        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();
                df.setMinimumIntegerDigits(0);
                double n = 0;
                System.out.println(n + ": '" + df.format(n) + "'");
                n = 0.1;
                System.out.println(n + ": '" + df.format(n) + "'");

            }

        }

        ---------Output from the test---------------------
        0.0: ''
        0.1: '.1'
        --------------------------------------------------

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

              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: