JDK-6712094 : DateFormat produces incorrect short date pattern for en_GB locale
  • Type: Bug
  • Component: globalization
  • Sub-Component: locale-data
  • Affected Version: 6u6
  • Priority: P4
  • Status: Closed
  • Resolution: Won't Fix
  • OS: windows_xp
  • CPU: x86
  • Submitted: 2008-06-09
  • Updated: 2015-07-10
  • Resolved: 2013-06-19
Related Reports
Relates :  
Description
FULL PRODUCT VERSION :
java version "1.5.0_15"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_15-b04)
Java HotSpot(TM) Client VM (build 1.5.0_15-b04, mixed mode, sharing)
1.6.0_06-b02

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

A DESCRIPTION OF THE PROBLEM :
When using DateFormat class with DateFormat.SHORT style and en_GB locale (Locale.UK), the expected pattern is dd/MM/yyyy as per the short date format defined here:

http://unicode.org/cldr/data/common/main/en_GB.xml

Actual pattern used by the DateFormat class is: dd/MM/yy


REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale;

import junit.framework.TestCase;

public class TestDateFormat extends TestCase {

    public void testDateFormat() {
        Date now = new Date();
        String expected = new SimpleDateFormat("dd/MM/yyyy", Locale.UK).format(now);
        String actual = DateFormat.getDateInstance(DateFormat.SHORT, Locale.UK).format(now);
        
        assertEquals(expected, actual);
    }
    
}
---------- END SOURCE ----------

Comments
As mentioned in previous comments, with locale data adapter feather in Java 8, the bug is solved by setting system property java.locale.providers to CLDR. In command line, -Djava.locale.providers=CLDR Directly modifying the date format pattern in JRE adapter itself may cause compatibility issue when parsing the input text into Date.
19-06-2013

It may bring the compatibility issue in parsing the input after the change. With https://jbs.oracle.com/bugs/browse/JDK-6336885 is integrated in Java 8, by specifying the system property java.locale.providers to CLDR, the correct value will be returned. Suggested solution: Use CLDR adapter in Java 8. For example, -Djava.locale.providers=CLDR in command line. In this way, format defined in CLDR will be used. After further check, I will close the issue.
30-05-2013

EVALUATION Transfer to jiri for locale element CR.
10-06-2008