Uploaded image for project: 'Harmony'
  1. Harmony
  2. HARMONY-107

java.text.DecimalFormat does not parse infinite values correctly

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Duplicate
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: Classlib
    • Labels:
      None

      Description

      In Java 1.4.2 Spec of java.text.DecimalFormat.parse(String, ParsePosition), it's said:
      Values that cannot fit into a Long are returned as Doubles. This includes values with a fractional part, infinite values, NaN, and the value -0.0.

      The test cases will fail if excuting under Harmony and pass on RI:

      // Test whether DecimalFormat can parse Positive infinity correctly
      public void testParseInfinityBigDecimalFalse()

      { DecimalFormat format = (DecimalFormat) DecimalFormat.getInstance(); DecimalFormatSymbols symbols = new DecimalFormatSymbols(); Number number = format.parse(symbols.getInfinity(), new ParsePosition(0)); assertTrue(number instanceof Double); assertTrue(Double.isInfinite(number.doubleValue())); }

      // Test whether DecimalFormat can parse Negative infinity correctly
      public void testParseMinusInfinityBigDecimalFalse()

      { DecimalFormat format = (DecimalFormat) DecimalFormat.getInstance(); DecimalFormatSymbols symbols = new DecimalFormatSymbols(); Number number = format.parse("-" + symbols.getInfinity(), new ParsePosition(0)); assertTrue(number instanceof Double); assertTrue(Double.isInfinite(number.doubleValue())); }

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                Unassigned
                Reporter:
                richard_liang Richard Liang
              • Votes:
                0 Vote for this issue
                Watchers:
                0 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: