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

Vietnamese currency display incorrectly

    XMLWordPrintable

Details

    • generic
    • generic
    • Verified

    Description

      FULL PRODUCT VERSION :
      java version "1.8.0_112"
      Java(TM) SE Runtime Environment (build 1.8.0_112-b16)
      Java HotSpot(TM) 64-Bit Server VM (build 25.112-b16, mixed mode)

      ADDITIONAL OS VERSION INFORMATION :
      Darwin Dos-MacBook-Pro.local 16.1.0 Darwin Kernel Version 16.1.0: Thu Oct 13 21:26:57 PDT 2016; root:xnu-3789.21.3~60/RELEASE_X86_64 x86_64

      A DESCRIPTION OF THE PROBLEM :
      I am living in Hanoi, Vietnam.
      ----------------------------------------------------------------------------------------------
      package oop;

      import java.text.NumberFormat;
      import java.util.Locale;

      public class CurrencyPrinter {

          public static void main(String[] args) {
              double amount = 1234567.8901234;
              NumberFormat nf = NumberFormat.getCurrencyInstance();
              System.out.println(nf.format(amount));
              System.out.println();

              nf = NumberFormat.getCurrencyInstance(Locale.FRANCE);
              System.out.println(nf.format(amount));
              System.out.println();

              System.out.println(nf.getClass().getName());
          }

      }

      -------------------------------------------------------------------------------
      Result:

      VND1,234,568

      1 234 567,89 €

      java.text.DecimalFormat
      -------------------------------------------------------------------------------


      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      1.234.568 VND


      (In Vietnam, 3-digits group separator is dot character)
      ACTUAL -
      VND1,234,568

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      package oop;

      import java.text.NumberFormat;
      import java.util.Locale;

      public class CurrencyPrinter {

          public static void main(String[] args) {
              double amount = 1234567.8901234;
              NumberFormat nf = NumberFormat.getCurrencyInstance();
              System.out.println(nf.format(amount));
              System.out.println();

              nf = NumberFormat.getCurrencyInstance(Locale.FRANCE);
              System.out.println(nf.format(amount));
              System.out.println();

              System.out.println(nf.getClass().getName());
          }

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

      Attachments

        Activity

          People

            ljiang Leo Jiang (Inactive)
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: