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

SHORT DATE output incorrect for South African locale in SimpleDateFormat

XMLWordPrintable

      FULL PRODUCT VERSION :
      java version "1.6.0_01"
      Java(TM) SE Runtime Environment (build 1.6.0_01-b06)
      Java HotSpot(TM) Client VM (build 1.6.0_01-b06, mixed mode, sharing)

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

      A DESCRIPTION OF THE PROBLEM :
      When using the locale en_ZA,
      current locale:en_ZA
      01/01/29 01:01
      2001/01/29 01:01
      29 January 2001 01:01



      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Compile and execute the attached source code

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      current locale:en_ZA
      29/01/01 01:01
      29/01/2001 01:01
      29 January 2001 01:01
      ACTUAL -
      current locale:en_ZA
      01/01/29 01:01
      2001/01/29 01:01
      29 January 2001 01:01


      ERROR MESSAGES/STACK TRACES THAT OCCUR :
      the date locale format for South Africa is incorrect.

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      Compile and run the following Java program:

      import java.text.DateFormat;
      import java.text.SimpleDateFormat;
      import java.util.*;
      import java.text.*;

      public class TestDate {

      public static void main(String[] argv) {

      DateFormat formatter1 = new SimpleDateFormat("MM/dd/yy HH.mm.ss");
      Date date = null;

      try {
      date = (Date)formatter1.parse("01/29/01 01.01.01");
      } catch (Exception e) { e.printStackTrace(); return; }

      System.out.println("current locale:"+Locale.getDefault());
      Locale locale = Locale.getDefault();
      DateFormat formatter2 = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT,locale);
      System.out.println(formatter2.format(date));
      formatter2 = DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.SHORT,locale);
      System.out.println(formatter2.format(date));
      formatter2 = DateFormat.getDateTimeInstance(DateFormat.LONG, DateFormat.SHORT,locale);
      System.out.println(formatter2.format(date));

      }

      }

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

            jtusla Jiri Tusla (Inactive)
            naoto Naoto Sato
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: