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

DateFormat produces incorrect short date pattern for en_GB locale

XMLWordPrintable

      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 ----------

            yhuang Yong Huang (Inactive)
            ndcosta Nelson Dcosta (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: