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

The Date String of Dutch Locale is incorrect

XMLWordPrintable

      FULL PRODUCT VERSION :
      java version "9.0.1"
      Java(TM) SE Runtime Environment (build 9.0.1+11)
      Java HotSpot(TM) 64-Bit Server VM (build 9.0.1+11, mixed mode)


      ADDITIONAL OS VERSION INFORMATION :
      Linux saber-ubuntu 4.4.0-45-generic #66-Ubuntu SMP Wed Oct 19 14:12:37 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux


      A DESCRIPTION OF THE PROBLEM :
      The Date String of Dutch Locale is changed from single D-M-YY to DD-MM-YY when month or day is just one number.

      REGRESSION. Last worked in version 8u152

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      It can be always reproduced when convert data object to string with Dutch locale.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      Test pass, the output string is 1-5-11
      ACTUAL -
      Test Fails, the output string is 01-05-11

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      Please use the test code below to reproduce the bug.

      package edu.utsa.cs.test4incomp;

      import java.text.DateFormat;
      import java.util.Calendar;
      import java.util.Locale;

      import org.junit.Test;

      import junit.framework.TestCase;

      public class TestCalendar001 extends TestCase{
      private static final Locale DUTCH_LOCALE = new Locale("nl", "NL");
      @Test
      public void testCalendar(){

      Calendar cal = Calendar.getInstance(DUTCH_LOCALE);
      cal.clear();
      cal.set(2011, Calendar.MAY, 1);

      final DateFormat dateFormat = getDateFormat(DUTCH_LOCALE);
      if (dateFormat != null)
      {
      String value = dateFormat.format(cal.getTime());
      assertEquals("1-5-11", value);

      }
      }

      public DateFormat getDateFormat(Locale locale)
      {
      if (locale == null)
      {
      locale = Locale.getDefault(Locale.Category.FORMAT);
      }

      // return a clone because DateFormat.getDateInstance uses a pool
      return (DateFormat) DateFormat.getDateInstance(DateFormat.SHORT, locale).clone();
      }

      }

      ---------- END SOURCE ----------

            psonal Pallavi Sonal (Inactive)
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: