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

Number of digits for 'year' in DateFormat.MEDIUM changes with Locale

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P4 P4
    • 1.4.0
    • 1.3.0
    • globalization
    • beta2
    • generic
    • generic



      Name: boT120536 Date: 04/12/2001


      java version "1.3.0_02"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.0_02)
      Java HotSpot(TM) Client VM (build 1.3.0_02, mixed mode)

      The number of digits used to display the year and the way the month is
      displayed in the DateFormat.MEDIUM format changes with the Locale used, some
      Locales show the year as '2001' others as '01' some display the month as '04'
      others using abbriviation. This seems to be related to the problem described in
      bug 4175300 where sun promises to change the MEDIUM format to use 4 digits for
      year, it seems this is only true for some countries/languages.

      The following code prints a list of MEDIUM formatted dates for every available
      locale:

          Locale[] allLocales = Locale.getAvailableLocales();
          for (int i = 0; i < allLocales.length; i++) {
              SimpleDateFormat sdf
                  = (SimpleDateFormat) DateFormat.getDateInstance(
                          DateFormat.MEDIUM, allLocales[i]);
              System.out.println(allLocales[i].getDisplayName()
                   + " \t\t\t " + sdf.format(new Date()));
          }

      Some of the output looks like this (cut to show some variations):

      English Apr 12, 2001
      English (United States) Apr 12, 2001
      (..)
      English (Canada) 12-Apr-01
      (..)
      Icelandic (Iceland) 12.4.2001
      Chinese (Taiwan) 2001/4/12

      This feature does not give me much trouble, but I feel very stupid telling my
      users to change their language/country setting from Dutch/Netherlands to
      English/US to display years in a y2k-save manner.
      (Review ID: 120661)
      ======================================================================

            mfang Michael Fang (Inactive)
            bonealsunw Bret O'neal (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: