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

getFirstDayOfWeek() in java.util.Calendar returns 1 for non supported locales

    XMLWordPrintable

    Details

    • Type: Enhancement
    • Status: Closed
    • Priority: P5
    • Resolution: Duplicate
    • Affects Version/s: 6u10
    • Fix Version/s: None
    • Component/s: core-libs
    • Labels:

      Description

      A DESCRIPTION OF THE REQUEST :
      The context in our case is that we should develop applications in diferent languages that are not supported by default in the JDK. The local administrations force us to support Basque, Calatan or Galician in our applications.

      Using the new service provider, we have defined a DateFormatSymbols provider for the Basque locale ("eu"), it works perfect. The problem arises when we use java.util.Calendar functionality.

      The question is that the getFirstDayOfWeek() method in java.util.Calendar returns 1 for non supported locales and it shuould be 2 in our case. The problem for us is that it is not posible to add new localized CalendarData to the JRE.



      JUSTIFICATION :
      This is really necesary as most of the developments are supported over third party libraries that uses standard Calendar functionality. An example of this third party libraries are the JSF components o Swing implementations that render calendars.

      JDK 6 avance in the support of non standard locales by providing the SPI functionality but the calender is out of this imporvemente. This functionality is necessary in context where different languages co-exists where the use of Java will be limited due local aminitration restrictions and support of these languages is a necessary requisite.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      I think that it could be two solutions:

      - The complete one is to allow the definition of new CalendarData for non standard locales. As it is possible for DateFormatSymbols.

      - The second one could be to allow the definition of the default locale when the preferred is not available. In our case is correct if the Spanish locale is used for calendar data.
      ACTUAL -
      The getFirstDayOfWeek() method in java.util.Calendar returns 1 for non supported locales even when all the system is configured for a locale where the first day of the Week is 2.

      ---------- BEGIN SOURCE ----------
      import java.util.Calendar;
      import java.util.GregorianCalendar;
      import java.util.Locale;

      public class LocaleDemo {
         
          public static void main(String[] args) {
              Locale.setDefault(new Locale("es","ES"));
              Calendar cal =GregorianCalendar.getInstance(new Locale("eu","ES"));
              System.out.println(cal.getFirstDayOfWeek());
              cal =GregorianCalendar.getInstance(new Locale("eu"));
              System.out.println(cal.getFirstDayOfWeek());
          }
      -- Result is always 1 and should be 2
      }
      ---------- END SOURCE ----------

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              naoto Naoto Sato
              Reporter:
              ndcosta Nelson Dcosta (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: