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

java.time.Duration missing isPositive method

XMLWordPrintable

    • Icon: CSR CSR
    • Resolution: Approved
    • Icon: P4 P4
    • 18
    • core-libs
    • None
    • minimal
    • This is a new method on a final class, so the compatibility risk is minimal.
    • Java API
    • SE

      Summary

      Provide isPositive() method in java.time.Duration.

      Problem

      There are isNegative() and isZero() methods in the class, but missing isPositive().

      Solution

      Add isPositive() method for completeness.

      Specification

      Add the following isPositive() method in java.time.Duration class.

      /**
       * Checks if this duration is positive, excluding zero.
       * <p>
       * A {@code Duration} represents a directed distance between two points on
       * the time-line and can therefore be positive, zero or negative.
       * This method checks whether the length is greater than zero.
       *
       * @return true if this duration has a total length greater than zero
       * @since 18
       */
      public boolean isPositive()

            naoto Naoto Sato
            rriggs Roger Riggs
            Brian Burkhalter, Iris Clark, Joe Wang, Lance Andersen, Roger Riggs
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: