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

Full date format in DateFormat does not include day of the week for UK locale

    Details

    • Subcomponent:
    • Resolved In Build:
      b96
    • CPU:
      x86
    • OS:
      linux

      Backports

        Description

        FULL PRODUCT VERSION :
        1.4.2_10, 5.0_06

        ADDITIONAL OS VERSION INFORMATION :
        Linux daffy 2.6.15-1-686 #1 Wed Jan 18 15:04:35 UTC 2006 i686 GNU/Linux


        A DESCRIPTION OF THE PROBLEM :
        The UK full format for UK locale dates does not include the day of the week. I don't see why the US and Canada full formats should include the day of the week and not the UK one. If I code the pattern by hand it works fine. Unfortunatly as I am developing a J2EE web application (JBoss with Sun's JDK) I am using the locale provide by the broswer.

        STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
        See code

        EXPECTED VERSUS ACTUAL BEHAVIOR :
        EXPECTED -
        UK full date pattern: EEEE, d MMMM yyyy
        UK long date pattern: dd MMMM yyyy

        US full date pattern: EEEE, MMMM d, yyyy
        US long date pattern: MMMM d, yyyy

        CA full date pattern: EEEE, MMMM d, yyyy
        CA long date pattern: MMMM d, yyyy

        UK full date: Tuesday, 7 February 2006
        UK long date: 07 February 2006

        US full date: Tuesday, February 7, 2006
        US long date: February 7, 2006

        CA full date: Tuesday, February 7, 2006
        CA long date: February 7, 2006

        By Hand: Tuesday, 7 February 2006

        ACTUAL -
        UK full date pattern: dd MMMM yyyy
        UK long date pattern: dd MMMM yyyy

        US full date pattern: EEEE, MMMM d, yyyy
        US long date pattern: MMMM d, yyyy

        CA full date pattern: EEEE, MMMM d, yyyy
        CA long date pattern: MMMM d, yyyy

        UK full date: 07 February 2006
        UK long date: 07 February 2006

        US full date: Tuesday, February 7, 2006
        US long date: February 7, 2006

        CA full date: Tuesday, February 7, 2006
        CA long date: February 7, 2006

        By Hand: Tuesday, 7 February 2006


        REPRODUCIBILITY :
        This bug can be reproduced always.

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

        class UKDateBug {

            public static void main (String argv[] ) {

                /*using explicit constant for locale*/
                DateFormat dfFullUK = DateFormat.getDateInstance(DateFormat.FULL, Locale.UK);
                DateFormat dfFullUS = DateFormat.getDateInstance(DateFormat.FULL, Locale.US);
                DateFormat dfFullCA = DateFormat.getDateInstance(DateFormat.FULL, Locale.CANADA);
                DateFormat dfLongUK = DateFormat.getDateInstance(DateFormat.LONG, Locale.UK);
                DateFormat dfLongUS = DateFormat.getDateInstance(DateFormat.LONG, Locale.US);
                DateFormat dfLongCA = DateFormat.getDateInstance(DateFormat.LONG, Locale.CANADA);
                GregorianCalendar now = new GregorianCalendar();

                System.out.println("UK full date pattern: " + ((SimpleDateFormat) dfFullUK).toPattern());
                System.out.println("UK long date pattern: " + ((SimpleDateFormat) dfLongUK).toPattern());
                System.out.println();
                System.out.println("US full date pattern: " + ((SimpleDateFormat) dfFullUS).toPattern());
                System.out.println("US long date pattern: " + ((SimpleDateFormat) dfLongUS).toPattern());
                System.out.println();
                System.out.println("CA full date pattern: " + ((SimpleDateFormat) dfFullCA).toPattern());
                System.out.println("CA long date pattern: " + ((SimpleDateFormat) dfLongCA).toPattern());
                System.out.println();
                System.out.println("UK full date: " + dfFullUK.format(now.getTime()));
                System.out.println("UK long date: " + dfLongUK.format(now.getTime()));
                System.out.println();
                System.out.println("US full date: " + dfFullUS.format(now.getTime()));
                System.out.println("US long date: " + dfLongUS.format(now.getTime()));
                System.out.println();
                System.out.println("CA full date: " + dfFullCA.format(now.getTime()));
                System.out.println("CA long date: " + dfLongCA.format(now.getTime()));

                SimpleDateFormat format = new SimpleDateFormat("EEEE, d MMMM yyyy", Locale.UK);
                System.out.println();
                System.out.println("By Hand: " + format.format(now.getTime()));
            }
        }

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

        CUSTOMER SUBMITTED WORKAROUND :
        Code the pattern by hand (see code) if you really must have a senstable UK format. I am letting the incomplete full version stand.

          Attachments

            Issue Links

              Activity

                People

                • Assignee:
                  jtusla Jiri Tusla (Inactive)
                  Reporter:
                  ndcosta Nelson Dcosta (Inactive)
                • Votes:
                  0 Vote for this issue
                  Watchers:
                  0 Start watching this issue

                  Dates

                  • Created:
                    Updated:
                    Resolved:
                    Imported:
                    Indexed: