Uploaded image for project: 'Wicket'
  1. Wicket
  2. WICKET-1692

on Java 6+ DatePicker.localize should use DateFormatSymbols.getInstance(Locale) instead of new DateFormatSymbols(Locale) to support DateFormatSymbolsProviders

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 1.3.3
    • Fix Version/s: 1.3.5, 1.4-RC1
    • Component/s: wicket-extensions
    • Labels:
      None
    • Environment:
      Sun JDK 1.6.0

      Description

      Java 6.0 introduces very usefull possibility to add providers for Locale specific classes from java.text - for example for DateFormatSymbols it may be installed DateFormatSymbolsProvider.

      Unfortunately such providers are ignored when DateFormatSymbols are created using constructor DateFormatSymbols(Locale) as it's used in DatePicker.localize method.

      Javadoc says clearly:
      "This constructor can only construct instances for the locales supported by the Java runtime environment, not for those supported by installed DateFormatSymbolsProvider implementations. For full locale coverage, use the getInstance method. "

      So please change DatePicker to support custom DateFormatSymbolsProviders.

      My proposal:

      protected void localize(Map widgetProperties)
      {
      DateFormatSymbols dfSymbols = new DateFormatSymbols(getLocale());
      try
      {
      // try to use JDK 6 DateFormatSymbols.getInstance(Locale)
      Method getInstanceMethod = DateFormatSymbols.getMethod("getInstance", new Class[]

      { Locale.class}

      );
      dfSymbols = (DateFormatSymbols)getInstanceMethod.invoke(null, new Object[]

      { getLocale() }

      );
      }catch(NoSuchMethodException e)

      { // pre JDK 6 - ignore }catch(IllegalAccessException e) { // pre JDK 6 - ignore }

      catch(IllegalArgumentException e)

      { // pre JDK 6 - ignore }catch(InvocationTargetException e) { // pre JDK 6 - ignore }

        Attachments

          Activity

            People

            • Assignee:
              jcompagner Johan Compagner
              Reporter:
              dgolda Damian Golda
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: