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

NumberFormat should allow leading spaces rather than zeros

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Duplicate
    • Icon: P4 P4
    • None
    • 5.0
    • core-libs
    • x86
    • windows_xp

      A DESCRIPTION OF THE REQUEST :
      The NumberFormat class is a nice class and has many great methods, but one thing that has always been troublesome is that fact that you can never enter a number format that has a leading space. You can do this with 0's but that is it. The "###" format will trim excess spaces and cause the whole idea behind the formatting to unravel.

      JUSTIFICATION :
      I have been in situations numerous times where I need to format a number and ALSO format the space it takes up. For example on a Y-Axis of a graph or any other component that might be affect adversly if size was a variable thing in certain areas. If I had number rangin from 20-80 in one graph but 0-100 in another my graph changes size due to the NumberFormat no being consistent.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      I think if you specify "###" there should always be 3 characters and this possibly could be defined by the user.
      ACTUAL -
      It trims off the spaces for instance if the above example would have been a 20 it will give you back "20" rather than " 20".

      CUSTOMER SUBMITTED WORKAROUND :
      Making a hack with the ChoiceFormat is one way. But that is a total hack.
      ###@###.### 11/2/04 21:22 GMT

            nlindenbsunw Norbert Lindenberg (Inactive)
            gmanwanisunw Girish Manwani (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: