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

NumberFormat doesn't parse currency numbers correctly

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P4 P4
    • None
    • 1.3.0
    • core-libs
    • generic
    • generic



      Name: boT120536 Date: 05/06/2001


      java version "1.3.0_01"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.0_01)
      Java HotSpot(TM) Client VM (build 1.3.0_01, mixed mode)

      Try running this code:


      import java.text.*;

      public class A {
        public static void main(String args[]){
          NumberFormat f = NumberFormat.getCurrencyInstance();
          try {
           Number number = f.parse("$456.66i");
           System.out.println( "test1 = "+ f.format(number));

           number = f.parse("$456.6,6.43,4.");
           System.out.println( "test2 = "+ f.format(number));

           number = f.parse("$4Thisisveryunusualdollaramountthatstillgetsparsed!!!5666.44");
           System.out.println( "test3 = "+ f.format(number));
          }
          catch(Exception e) {
           System.out.println("Exception: "+e);
          }
        }
      }


      All the currency numbers used for parsing, contain characters that are not
      supposed to be there, but .parse() method still doesn't throw exception.
      (Review ID: 123116)
      ======================================================================

            nlindenbsunw Norbert Lindenberg (Inactive)
            bonealsunw Bret O'neal (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: