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

SimpleDateFormat should link to DateTimeFormatter

XMLWordPrintable

    • Icon: CSR CSR
    • Resolution: Approved
    • Icon: P4 P4
    • 17
    • 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

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

              Created:
              Updated:
              Resolved: