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

Incorrect date format for Russian locale - months names are not conjugated

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P4
    • Resolution: Duplicate
    • Affects Version/s: 6u10
    • Fix Version/s: None
    • Component/s: core-libs
    • Labels:
    • Subcomponent:
    • CPU:
      x86
    • OS:
      windows_xp

      Description

      FULL PRODUCT VERSION :
      java version "1.5.0_12"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_12-b04)
      Java HotSpot(TM) Client VM (build 1.5.0_12-b04, mixed mode, sharing)

      Also applicable to latest versions, including

      java version "1.6.0_10-beta"
      Java(TM) SE Runtime Environment (build 1.6.0_10-beta-b25)
      Java HotSpot(TM) Client VM (build 11.0-b12, mixed mode, sharing)

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

      A DESCRIPTION OF THE PROBLEM :
      When formatting dates with SimpleDateFormat class in "ru" or "ru_RU" locale, the month names are printed incorrectly. It occures due to wrong values in sun.text.resources.LocaleElements_ru (FormatData_ru in 1.6).

      The Russian language has specific suffixes for months when they mentioned together with dates (replacement for "of" word in English). So in transcription March will be "mart" when 1st of March will be '1oe marta'. It concerns all months - they all must have different endings.

      Another thing is that first letter should NOT be capitalized.

      See "be" (Belarus), "uk" (Ukraine) months data for correct implementation.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Use DateFormat class or SimpleDateFormat class with default DateFormatSymbols set to output date in "ru" locale with LONG description. You'll see that months are printed capitalized and not properly suffixed. For example consider following code snippet:

      Locale locRu = new Locale("ru");
      SimpleDateFormat rudf = new SimpleDateFormat("dd MMMM yy", locRu);
      Date date = new GregorianCalendar(1983, 2, 21).getTime();
      System.out.write(rudf.format(date).getBytes("Cp1251"));

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      21 ¿¿¿¿¿ 83
      ACTUAL -
      21 ¿¿¿¿ 83

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      import java.io.IOException;
      import java.text.DateFormatSymbols;
      import java.text.SimpleDateFormat;
      import java.util.Date;
      import java.util.GregorianCalendar;
      import java.util.Locale;

      public class SalutWorld {

        public static void main(String[] args) {
          Locale locRu = new Locale("ru");
          SimpleDateFormat rudf = new SimpleDateFormat("dd MMMM yy", locRu);
          Date date = new GregorianCalendar(1983, 2, 21).getTime();
          try {
            System.out.write(rudf.format(date).getBytes("Cp1251"));
          } catch (IOException e) {
            e.printStackTrace();
          }
        }
      }
          
      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      The work around is to use custom date format symbols:

      DateFormatSymbols symbols = new DateFormatSymbols(locRu);
      String[] months = new String[]{
      "¿¿¿¿¿¿",
      "¿¿¿¿¿¿¿",
      "¿¿¿¿¿",
      "¿¿¿¿¿¿",
      "¿¿¿",
      "¿¿¿¿",
      "¿¿¿¿",
      "¿¿¿¿¿¿¿",
      "¿¿¿¿¿¿¿¿",
      "¿¿¿¿¿¿¿",
      "¿¿¿¿¿¿",
      "¿¿¿¿¿¿¿"
      };
      symbols.setMonths(months);

      SimpleDateFormat df = new SimpleDateFormat("dd MMMM yy", symbols);

        Attachments

          Issue Links

            Activity

              People

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

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Imported:
                  Indexed: