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

java.time.Duration is lacking comparison methods isLongerThan() / isShorterThan() / isEqual()

XMLWordPrintable

    • x86_64
    • linux

      A DESCRIPTION OF THE REQUEST :
      Having to compare durations is a common programming problem ; being forced to use compareTo() leads to code that is both hard to read and error-prone.

      JUSTIFICATION :
      I have a lot of understanding for wanting to have a minimal/orthogonal API but in this case the use-case (comparing durations) is just so common that IMHO it's worth adding these methods.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      Duration instances should be comparable using isLongerThan() / isShorterThan() / isEqual() methods.
      ACTUAL -
      Currently durations can only be compared using the compareTo() method.

      CUSTOMER SUBMITTED WORKAROUND :
      None available.

            rriggs Roger Riggs
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: