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

DecimalFormat percentage format can contain unexpected %

    XMLWordPrintable

    Details

    • Subcomponent:
    • Resolved In Build:
      b139
    • CPU:
      generic
    • OS:
      generic
    • Verification:
      Verified

      Backports

        Description

        FULL PRODUCT VERSION :
        java version "1.8.0_40"
        Java(TM) SE Runtime Environment (build 1.8.0_40-b27)
        Java HotSpot(TM) 64-Bit Server VM (build 25.40-b25, mixed mode)


        ADDITIONAL OS VERSION INFORMATION :
        Windows Server 2012, OSX

        A DESCRIPTION OF THE PROBLEM :
        Multiple calls to DecimalFormat when formatting percentages can lead to extra % in the output

        REGRESSION. Last worked in version 7u80

        ADDITIONAL REGRESSION INFORMATION:
        java version "1.7.0_80"
        Java(TM) SE Runtime Environment (build 1.7.0_80-b15)
        Java HotSpot(TM) 64-Bit Server VM (build 24.80-b11, mixed mode)

        EXPECTED VERSUS ACTUAL BEHAVIOR :
        EXPECTED -
        0.006%
        0%
        0.006%
        ACTUAL -
        0.006%
        0%
        0%006%

        REPRODUCIBILITY :
        This bug can be reproduced occasionally.

        ---------- BEGIN SOURCE ----------
        import java.text.*;

        public class DecFormats {

        public static void main(String[] args) {
        DecimalFormat nf = (DecimalFormat) DecimalFormat.getPercentInstance(new java.util.Locale("en_US"));
        nf.setMaximumFractionDigits(3);
        nf.setMinimumFractionDigits(0);
        nf.setMultiplier(1);
        System.out.println(nf.format(.005678));
        System.out.println(nf.format(0.0));
        System.out.println(nf.format(.005678));
        }

        }
        ---------- END SOURCE ----------

          Attachments

            Issue Links

              Activity

                People

                Assignee:
                nishjain Nishit Jain
                Reporter:
                webbuggrp Webbug Group
                Votes:
                0 Vote for this issue
                Watchers:
                4 Start watching this issue

                  Dates

                  Created:
                  Updated:
                  Resolved: