Forum Stats

  • 3,838,710 Users
  • 2,262,394 Discussions
  • 7,900,739 Comments

Discussions

Hungarian date format changed

3525328
3525328 Member Posts: 3
edited Oct 17, 2017 3:57AM in Java SE Early Access

Hungarian date format has been changed in jdk-9+181.

The short format was (in Java8) "yyyy.MM.dd." e.g. "2017.08.18.".

In Java9 it is "y. MM. dd." e.g. "2017. 08. 18." (extra space after the dots).

I do not know why. It causes compatibility problems.

3525328

Answers

  • Pallavi Sonal-Oracle
    Pallavi Sonal-Oracle Member Posts: 7
    edited Aug 22, 2017 2:50AM

    I tried with JDK 9-ea+181 on Windows 7 and don't see any extra space after the dots while using SHORT date format for the locale ("hr", "HR"). Following is the output I got - 22.08.2017.

    Can you please specify the exact locale that you used ?

  • 3525328
    3525328 Member Posts: 3
    edited Aug 22, 2017 12:31PM

    Linux (SLES11)

    Java(TM) SE Runtime Environment (build 9+181)

    Java HotSpot(TM) 64-Bit Server VM (build 9+181, mixed mode)

    Date today = new Date();

    SimpleDateFormat format = (SimpleDateFormat) DateFormat.getDateInstance(DateFormat.SHORT, new Locale("hu","HU"));

    System.out.println(format.toPattern());

    System.out.println(format.format(today));

    y. MM. dd.

    2017. 08. 22.

  • Pallavi Sonal-Oracle
    Pallavi Sonal-Oracle Member Posts: 7
    edited Sep 5, 2017 4:54AM

    With JDK 9, the default locale data provider is changed to CLDR. Refer : JDK-8043554. As per the CLDR , the date format for Hungarian Locale is "GGGGG y. M. d." , hence the change. If you require the same format as in JDK 8 when the default locale data provider was JRE, you can use the option : -Djava.locale.providers=JRE

    35253283525328
  • 3525328
    3525328 Member Posts: 3
    edited Oct 17, 2017 3:57AM

    Thank you, it does work.

    However I do not understand why the default behaviour has been changed.