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

(fmt) Errors in Hungarian locale-specific formatting

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: P4 P4
    • None
    • 5.0
    • core-libs
    • x86
    • windows_xp

      FULL PRODUCT VERSION :
      java version "1.5.0_06"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_06-b05)
      Java HotSpot(TM) Client VM (build 1.5.0_06-b05, mixed mode, sharing)

      ADDITIONAL OS VERSION INFORMATION :
      Microsoft Windows XP [Version 5.1.2600]

      EXTRA RELEVANT SYSTEM CONFIGURATION :
      JDK 1.5.0_04 (javac)
      JRE 1.5.0_06 (java)

      A DESCRIPTION OF THE PROBLEM :
      The i18n API (java.util.Formatter, java.text.DecimalFormat) returns incorrect output in some cases for Hungarian. I have found two such cases:

      1. When formatting with a Hungarian locale (HU_hu or HU), and java.util.Formatter puts the morning/afternoon marker after the time for 'tr'. The documentation states that "The location of the morning or afternoon marker ('%Tp') may be locale-dependent.". In Hungarian, we put this marker before the hour, so for example "du. 2" instead of "2 du". As for the inclusion of '.' after de/du , it depends; however, I think the "correct" way is to include it.

      2. If a number is formatted with CurrencyFormat in the HU_hu locale, it will return 'Ft<number>'. However, in Hungarian, the currency should come after the number, with a space between them: '<number> Ft'.

      Moreover, CurrencyFormat returns an asterisk-like character ('¤') when the locale HU is used. The default locale on my computer is Locale.US, so I think it should return either 'Ft' or '$', but not '¤'.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Please refer to the source code.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      DU. 04:55:59-kor 1 234 567 Ft-ot költöttem el.
       
      ACTUAL -
      04:55:59 DU-kor ¤ 1 234 567,00-ot költöttem el.
      04:55:59 DU-kor Ft1 234 567-ot költöttem el.
       

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      import java.util.*;
      import java.text.*;
      import javax.swing.*;
      import java.awt.*;

      public class FormatErrorProof {
      public static void main(String[] args) {
      Locale l1 = new Locale("HU");
      Locale l2 = new Locale("HU", "hu");

      NumberFormat nf1 = NumberFormat.getCurrencyInstance(l1);
      NumberFormat nf2 = NumberFormat.getCurrencyInstance(l2);
      String curr1 = nf1.format(1234567);
      String curr2 = nf2.format(1234567);

      Date d = new Date();

      String proof1 = String.format(l1, "%tr-kor %s-ot költöttem el.%n", d, curr1);
      String proof2 = String.format(l2, "%tr-kor %s-ot költöttem el.%n", d, curr2);

      JFrame frame = new JFrame("Format error in Hungarian");

      Font f = Font.getFont("Times New Roman");
      JLabel lbl1 = new JLabel(proof1);
      JLabel lbl2 = new JLabel(proof2);
      lbl1.setFont(f);
      lbl2.setFont(f);

      frame.getContentPane().setLayout(new FlowLayout());
      frame.add(lbl1);
      frame.add(lbl2);
      frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
      frame.pack();
      frame.setVisible(true);
      }
      }
      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      For the error of the Formatter, instead of %tr, "%tp. %tI:%tM:%tS" should be used (uppercase morning/afternoon markers are not used much in Hungarian, anyway).

      For the other error, NumberFormatter can be used and the "Ft" can be added manually.

      However, as these classes are mostly used for i18n, these workarounds result in a very cluttered code instead of having the same code for all languages.

            Unassigned Unassigned
            okutsu Masayoshi Okutsu
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Imported:
              Indexed: