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

NumberFormat.format(Object number, should take in a Number

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Not an Issue
    • Icon: P4 P4
    • None
    • 1.2.0
    • core-libs
    • generic
    • generic



      Name: clC74495 Date: 05/31/98


      ===================================================================
      Carlos.Lucasius@Canada (May 31, 1998):
      This RFE was initially reported for JDK1.1.6, but it also
      applies to JDK1.2beta4.

      Report follows:

      Consider in java.text.NumberFormat.java the following
      method definition:

      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");
      }
      }

      It takes in an Object as input, but within the code you are
      checking to see if the object is at least an instance of Number.
      This being the case, why don't you take a Number as input
      rather than an Object. This would make better compile time
      checking, and less internal work (quicker!)

      (Review ID: 29410)
      ======================================================================

            aliusunw Alan Liu (Inactive)
            clucasius Carlos Lucasius (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: