SimpleDateFormat should link to DateTimeFormatter

XMLWordPrintable

    • Type: CSR
    • Resolution: Approved
    • Priority: P4
    • 17
    • Component/s: core-libs
    • None
    • minimal
    • This is a document-only fix.
    • Java API
    • SE

      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
      

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

              Created:
              Updated:
              Resolved: