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

Full date format in DateFormat does not include day of the week for SV/DA locale

    XMLWordPrintable

    Details

      Description

      FULL PRODUCT VERSION :
      (happens in Java 1.6 as well)

      java version "1.7.0"
      Java(TM) SE Runtime Environment (build 1.7.0-b147)
      Java HotSpot(TM) Server VM (build 21.0-b17, mixed mode)

      ADDITIONAL OS VERSION INFORMATION :
      Windows XP, Ubuntu 10.04.3

      A DESCRIPTION OF THE PROBLEM :
      Using Danish ("DA") or Swedish ("SV") locale with:

      DateInstance.getDateInstance( DateFormat.FULL, locale)

      results in an incorrect date string. The string does not contain the day of the week even though it does in the English ("EN") and Italian ("IT") locales.

      This inconsistency should not exist across locales. The documentation says that "FULL" should be fully specified and gives an example contains the day of the week.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Run source code below.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      All patterns should contain the day of the week, and the formatted outputs should contain the day of the week.
      ACTUAL -
      US full date pattern: EEEE, MMMM d, yyyy
      IT long date pattern: EEEE d MMMM yyyy
      SV full date pattern: 'den 'd MMMM yyyy
      DA full date pattern: d. MMMM yyyy

      US full date: Wednesday, October 26, 2011
      IT long date: mercoledì 26 ottobre 2011
      SV full date: den 26 oktober 2011
      DA full date: 26. oktober 2011


      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      public class Tmp {
          public static void main (String argv[] ) {

              Locale usLocale = new Locale("en");
              Locale italyLocale = new Locale("it");
              Locale swedenLocale = new Locale("sv");
              Locale denmarkLocale = new Locale("da");
              /*using explicit constant for locale*/
              DateFormat dtUS = DateFormat.getDateInstance (DateFormat.FULL, usLocale );
              DateFormat dtIT = DateFormat.getDateInstance (DateFormat.FULL, italyLocale );
              DateFormat dtSV = DateFormat.getDateInstance (DateFormat.FULL, swedenLocale) ;
              DateFormat dtDA = DateFormat.getDateInstance (DateFormat.FULL, denmarkLocale );
              GregorianCalendar now = new GregorianCalendar();

              System.out.println("US full date pattern: " + ((SimpleDateFormat) dtUS).toPattern());
              System.out.println("IT long date pattern: " + ((SimpleDateFormat) dtIT).toPattern());
              System.out.println("SV full date pattern: " + ((SimpleDateFormat) dtSV).toPattern());
              System.out.println("DA full date pattern: " + ((SimpleDateFormat) dtDA).toPattern());
              System.out.println();
              System.out.println("US full date: " + dtUS.format(now.getTime()));
              System.out.println("IT long date: " + dtIT.format(now.getTime()));
              System.out.println("SV full date: " + dtSV.format(now.getTime()));
              System.out.println("DA full date: " + dtDA.format(now.getTime()));
              System.out.println();
          }
      }

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

      CUSTOMER SUBMITTED WORKAROUND :
      Specify a custom format string. This is suboptimal since the goal of using DateFormat.FULL is to avoid having to do localization yourself.

        Attachments

          Activity

            People

            Assignee:
            yhuang Yong Huang (Inactive)
            Reporter:
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: