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

DecimalFormat: Negative format ignored

    XMLWordPrintable

    Details

    • Subcomponent:
    • Resolved In Build:
      1.1.6
    • CPU:
      x86
    • OS:
      windows_nt
    • Verification:
      Verified

      Backports

        Description



        Name: joT67522 Date: 11/12/97


        The negative portion of the number format in DecimalFormat is being ignored.
        Behavior is as if the negative format were not being entered at all.

        import java.lang.*;
        import java.text.*;

        public class TestApp extends java.lang.Object
        {
          public static void main(java.lang.String[] args)
          {
            DecimalFormat dfFoo;
            
            dfFoo = new DecimalFormat("0000;-000");
            System.out.println(dfFoo.toPattern());
            System.out.println(dfFoo.format(42));
            System.out.println(dfFoo.format(-42));
            System.out.println();
            
            dfFoo.applyPattern("000;-000");
            System.out.println(dfFoo.toPattern());
            System.out.println(dfFoo.format(42));
            System.out.println(dfFoo.format(-42));
            System.out.println();
            
            dfFoo.applyPattern("000;-0000");
            System.out.println(dfFoo.toPattern());
            System.out.println(dfFoo.format(42));
            System.out.println(dfFoo.format(-42));
            System.out.println();
            
            dfFoo.applyPattern("0000;-000");
            System.out.println(dfFoo.toPattern());
            System.out.println(dfFoo.format(42));
            System.out.println(dfFoo.format(-42));
            System.out.println();
            
            
          }
            
        }



        Produces the following erroneous output:

        #0000
        0042
        -0042

        #000
        042
        -042

        #000
        042
        -042

        #0000
        0042
        -0042
        (Review ID: 19374)
        ======================================================================

          Attachments

            Issue Links

              Activity

                People

                Assignee:
                joconnersunw John Oconner (Inactive)
                Reporter:
                johsunw Joon Oh (Inactive)
                Votes:
                0 Vote for this issue
                Watchers:
                0 Start watching this issue

                  Dates

                  Created:
                  Updated:
                  Resolved:
                  Imported:
                  Indexed: