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

SimpleDateFormat should link to DateTimeFormatter

    XMLWordPrintable

    Details

    • Type: CSR
    • Status: Closed
    • Priority: P4
    • Resolution: Approved
    • Fix Version/s: 17
    • Component/s: core-libs
    • Labels:
      None
    • Subcomponent:
    • Compatibility Risk:
      minimal
    • Compatibility Risk Description:
      This is a document-only fix.
    • Interface Kind:
      Java API
    • Scope:
      SE

      Description

      Summary

      Add a suggestion for using java.time.DateTimeFormatter instead of java.text.DateFormat/java.text.SimpleDateFormat.

      Problem

      The Synchronization section in both DateFormat and SimpleDateFormat does not suggest a better alternative.

      Solution

      Add an API note to use DateTimeFormatter as an alternative in both class descriptions.

      Specification

      In the class descriptions of java.text.DateFormat and java.text.SimpleDateFormat classes,

      Change the following paragraphs from:

       * Date formats are not synchronized.
       * It is recommended to create separate format instances for each thread.
       * If multiple threads access a format concurrently, it must be synchronized
       * externally.

      to:

       * Date formats are not synchronized.
       * It is recommended to create separate format instances for each thread.
       * If multiple threads access a format concurrently, it must be synchronized
       * externally.
       * @apiNote Consider using {@link java.time.format.DateTimeFormatter} as an
       * immutable and thread-safe alternative.

      Add the following @see tag:

       * @see          java.time.format.DateTimeFormatter

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              naoto Naoto Sato
              Reporter:
              alanb Alan Bateman
              Reviewed By:
              Brian Burkhalter, Lance Andersen, Roger Riggs
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: