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

DecimalFormat.parse accepts invalid input format

    XMLWordPrintable

    Details

    • Subcomponent:
    • CPU:
      generic
    • OS:
      generic

      Description

      A DESCRIPTION OF THE PROBLEM :
      new DecimalFormat(Locale.GERMAN).parse("10.200.55") returns 1020055.0 instead of reporting an error. According to ISO thousand separator grouping must be in triplets of numbers from right to left starting with the decimal sign. This is not the case with "10.200.55" having a two-group at the left. Proper string would be "1.020.055".

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      double result = new DecimalFormat(Locale.GERMAN).parse("10.200.55");

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      ParseException is thrown
      ACTUAL -
      1020055.0

      ---------- BEGIN SOURCE ----------
      See Steps to reproduce
      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      Implementing own code to check grouping.

      FREQUENCY : always


        Attachments

          Activity

            People

            Assignee:
            tongwan Andrew Wang
            Reporter:
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: