Clarify ZonedDateTime#toString() documentation regarding omitted zero seconds

XMLWordPrintable

    • Type: CSR
    • Resolution: Unresolved
    • Priority: P4
    • 27
    • Component/s: core-libs
    • None
    • minimal
    • This is a doc change only, clarifying the spec.
    • Java API
    • SE

      Summary

      Clarify the ZonedDateTime#toString() documentation to avoid misunderstanding with regard to zero seconds/nanoseconds

      Problem

      With the current wording/example, users may misread as if seconds value is always included, even if it is zero.

      Solution

      Refine the wording to clearly mention they are composed using LocalDateTime#toString() which explains the omission.

      Specification

      Change the method description of ZonedDateTime#toString() as follows:

            * Outputs this date-time as a {@code String}, such as
            * {@code 2007-12-03T10:15:30+01:00[Europe/Paris]}.
            * <p>
      -     * The format consists of the {@code LocalDateTime} followed by the {@code ZoneOffset}.
      +     * The format consists of the output of {@link LocalDateTime#toString()},
      +     * followed by the output of {@link ZoneOffset#toString()}.
      +     * If the time has zero seconds and/or nanoseconds, they are
      +     * omitted to produce the shortest representation.
            * If the {@code ZoneId} is not the same as the offset, then the ID is output.
            * The output is compatible with ISO-8601 if the offset and ID are the same,
            * and the seconds in the offset are zero.
      

            Assignee:
            Naoto Sato
            Reporter:
            Webbug Group
            Brian Burkhalter, Roger Riggs
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated: