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

java.text.SimpleDateFormat: toLocalizedPattern() returns inappropriate string for many locales

    XMLWordPrintable

    Details

      Backports

        Description

        I'm working on a web UI component that accepts calendar data. The
        component consists of (among other things) a textfield below which is
        supposed to be a localized hint representing the expected format of
        the date input, e.g. dd/mm/yyyy.

        The component uses a java.text.SimpleDateFormat internally, and I
        would like to use the toLocalizedPattern() method (and toLowerCase())
        to produce a default hint. By default I do not set the pattern to use,
        as SimpleDateFormat pattern will pick one that is appropriate for the
        locale.

        However, when I use toLocalizedPattern() method, I only appear to get
        a truly localized string for German (uuuu.MM.tt) . For other languages
        I tried, including Swedish, French and Asian languages) I get the same
        result as I would with toPattern(), that is, it is technically
        appropriate for the locale, but the representation is made up by
        strings that are only intelligible in English.

        FWIW, I am Swedish and have also lived in France. In neither of those
        countries do I remember having filled in a form where the suggested
        date format was represented to me using English letters. Using Google
        to search on Swedish pages I get twice as many hits for åååå-mm-dd as for
        yyyy-mm-dd (and if the first hits are representative, many of the
        yyyy-mm-dd are used in JavaScript code). For French I get more than
        four times as many hits for aaaa-mm-jj as for yyyy-mm-dd.

          Attachments

            Issue Links

              Activity

                People

                Assignee:
                yhuang Yong Huang (Inactive)
                Reporter:
                avonklo Ana Von Klopp (Inactive)
                Votes:
                0 Vote for this issue
                Watchers:
                3 Start watching this issue

                  Dates

                  Created:
                  Updated:
                  Resolved:
                  Imported:
                  Indexed: