Details

    • Type: CSR
    • Status: Draft
    • Priority: P4
    • Resolution: Unresolved
    • Fix Version/s: tbd
    • Component/s: core-libs
    • Labels:
      None
    • Subcomponent:
    • Compatibility Kind:
      source
    • Compatibility Risk:
      minimal
    • Compatibility Risk Description:
      These are additions of new methods.
    • Interface Kind:
      Java API
    • Scope:
      SE

      Description

      Summary

      Support additional date/time formats defined in CLDR

      Problem

      Currently java.time.format.DateTimeFormatter supports 4 pre-defined format styles, i.e, FormatStyle.FULL/LONG/MEDIUM/SHORT. Users cannot use more localized flexible formats such as format that contains only year and month.

      Solution

      Provide methods similar to DateTimeFormatter.ofPattern that take Skeleton patterns defined in CLDR. They will return localized formatters based on the passed skeletons.

      Specification

      Add the following methods to java.time.format.DateTimeFormatter class:

      /**
       * Creates a locale specific formatter using the specified Skeleton pattern for the default locale. Skeleton
       * pattern is based on CLDR's
       * <a href="http://cldr.unicode.org/translation/date-time-1/date-time-patterns#TOC-Additional-Date-Time-Formats">
       * Additional Date-Time Formats</a>.
       * For example, {@code yMMM} will format 2011-12-03 as 'Dec 2011'.
       * <p>
       * The formatter will use the {@link Locale#getDefault(Locale.Category) default FORMAT locale}.
       * This can be changed using the {@link #ofLocalizedPattern(String, Locale)} variant of this method.
       * <p>
       * The returned formatter has no override chronology or zone.
       * It uses {@link ResolverStyle#SMART SMART} resolver style.
       *
       * @param skeleton the skeleton pattern to use, not null
       * @return the formatter based on the pattern, not null
       * @throws IllegalArgumentException if the pattern is invalid
       * @see #ofPattern(String)
       */
      public static DateTimeFormatter ofLocalizedPattern(String skeleton)
      
      /**
       * Creates a locale specific formatter using the specified Skeleton pattern and locale. Skeleton
       * pattern is based on CLDR's
       * <a href="http://cldr.unicode.org/translation/date-time-1/date-time-patterns#TOC-Additional-Date-Time-Formats">
       * Additional Date-Time Formats</a>.
       * For example, {@code yMMM} will format 2011-12-03 as 'Dec 2011'.
       * <p>
       * The formatter will use the specified locale.
       * <p>
       * The returned formatter has no override chronology or zone.
       * It uses {@link ResolverStyle#SMART SMART} resolver style.
       *
       * @param skeleton the skeleton pattern to use, not null
       * @param locale  the locale to use, not null
       * @return the formatter based on the pattern, not null
       * @throws IllegalArgumentException if the pattern is invalid
       * @see #ofPattern(String, Locale)
       */
      public static DateTimeFormatter ofLocalizedPattern(String skeleton,
                                                        Locale locale)

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                naoto Naoto Sato
                Reporter:
                naoto Naoto Sato
              • Votes:
                0 Vote for this issue
                Watchers:
                0 Start watching this issue

                Dates

                • Created:
                  Updated: