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

RFE: No BigDecimalFormat & Format has and UNACCEPTABLE final method

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Duplicate
    • Icon: P4 P4
    • None
    • 1.1.4, 1.2.0
    • core-libs
    • x86, sparc
    • solaris_2.5, windows_95



      Name: rm29839 Date: 03/05/98


      /* Bug report dmg.bug1.1.5_0003 ("public final" makes numeric part
            ========== of java.text ALMOST USELESS)
            Code snippet follows
      */
      import java.text.NumberFormat;

      public abstract class DmgBug0002 extends NumberFormat { // actual class name is
                                                      // BigDecimalFormat
            public StringBuffer format(Object number,
                                    StringBuffer toAppendTo,
                                    FieldPosition pos) {
            if (! (number instanceof BigDecimal))
               return super.format(number, toAppendTo, pos);
            // actual processing of a BigDecimal
         }
      }

      /*
         COMPILE PROBLEM
           Final methods can't be overriden.

           inspecting the source:
          (extract from java.text.DecimalFormat);
          public final StringBuffer format(Object number,
                 =====
                 ?????
                                           StringBuffer toAppendTo,
                                           FieldPosition pos)
          {
              if (number instanceof Double || number instanceof Float) {
                  return format(((Number)number).doubleValue(), toAppendTo, pos);
              }
              else if (number instanceof Number) {
                  return format(((Number)number).longValue(), toAppendTo, pos);
                         ==================================== ???????????
              }
              else {
                  throw new IllegalArgumentException("Cannot format given Object as a Number");
              }
          }

          The problem exists in both JDK1.1.5 & JDK1.2 Beta 2.

          java.math.BigDecimal Implements java.lang.Number

          Double and Float are not acceptable in Commercial Applications,
          expecially Stock Exchange Trading where currency conversions are
          stated with with 4 SIGNIFICANT positions after the decimal point
          and where it is often necessary to cross calculate a conversion
          rate (eg. ISK -> DM -> PLZ).

          I was of the optinion that java.math.BigDecimal was intented both
          for jdbc applications AND FOR COMMERCIAL applications in java? But
          neither a java.[math|text].BigDecimalFormat exists nor is it easily
          possible really to extend java.lang.Number.

          Is nobody really using java for the mundane tasks of traditional
          commercial data processing?

          PLEASE PLEASE remove the 'final' marked above in the next releases
          (JDK 1.1.6 & JDK 1.2 ??? - beta 3 is probably already finalized by
          now so I don't know what will be the release after 1.2 beta 3).


          Platforms & SW Versions
          =======================
             MS-Win95 (Cyrix 6x86 200MX) (JDK1.2 beta 2) JDK 1.1.5 swing 1.0.1
             MS-WinNT (PentiumPro 200 MHz) (JDK1.2 beta 2) JDK 1.1.5 swing 1.0.1
             AIX 4.1 (PowerPC 128MHz) JDK 1.1.4 swing 1.0.1

        Hoping that this report helps you more than java.text has helped me in
        the commercial programming area.
        I remain
        yours faithfully

        David M. Gaskin
        (###@###.###).

      */
      (Review ID: 26048)
      ======================================================================

            aliusunw Alan Liu (Inactive)
            rmandelsunw Ronan Mandel (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: