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

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

    XMLWordPrintable

    Details

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

      Backports

        Description



        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'
        --------------------------------------------------

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

          Attachments

            Issue Links

              Activity

                People

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

                  Dates

                  Created:
                  Updated:
                  Resolved:
                  Imported:
                  Indexed: