com.versionone

## Class Duration

- java.lang.Object
- - com.versionone.Duration

-     public class Duration
      extends Object

  Class representing some duration of time

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `static class` | `Duration.Unit` Valid units for Duration

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `Duration()` Default constructor sets duration to 0 days
    `Duration(int amount, Duration.Unit units)` Create from amount and unit
    `Duration(String value)` Create instance from a String Expected format is "%d {Unit}" for example "3 Days" (without the quotes)

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `static boolean` | `compare(Duration a, Duration b)` Compare two Duration instances
    `boolean` | `equals(Object obj)` Compare this instance to another Duration
    `int` | `getAmount()` return the amount specified by this Duration
    `int` | `getDays()` Get amount of this Duration in days
    `Duration.Unit` | `getUnits()` return the units specified by this Duration
    `int` | `hashCode()` Get the hash code for this instance
    `static Duration` | `parse(String value)` Create a Duration from a String
    `String` | `toString()` Convert this instance to it's string representation (%d {Unit})

    - ### Methods inherited from class java.lang.Object

      `clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

- - ### Constructor Detail

    - #### Duration

          public Duration()

      Default constructor sets duration to 0 days

    - #### Duration

          public Duration(int amount,
                          Duration.Unit units)

      Create from amount and unit
      Parameters:
        `amount` - - amount value for this instance
        `units` - - unit value for this instance

    - #### Duration

          public Duration(String value)

      Create instance from a String Expected format is "%d {Unit}" for example "3 Days" (without the quotes)
      Parameters:
        `value` - - string value used to set amount and unit
      Throws:
        `IllegalArgumentException` - if thre is an error in parsing the value

  - ### Method Detail

    - #### getAmount

          public int getAmount()

      return the amount specified by this Duration
      Returns:
        integer

    - #### getUnits

          public Duration.Unit getUnits()

      return the units specified by this Duration
      Returns:
        Unit

    - #### getDays

          public int getDays()

      Get amount of this Duration in days
      Returns:
        int

    - #### compare

          public static boolean compare(Duration a,
                                        Duration b)

      Compare two Duration instances
      Parameters:
        `a` - - one instance
        `b` - - the other instance
      Returns:
        true if they are equal, false otherwise

    - #### parse

          public static Duration parse(String value)

      Create a Duration from a String
      Parameters:
        `value` - - string used to create
      Returns:
        an instance of Duration with value set from string
      See Also:
        `Duration(String)`

    - #### toString

          public String toString()

      Convert this instance to it's string representation (%d {Unit})
      Overrides:
        `toString` in class `Object`

    - #### equals

          public boolean equals(Object obj)

      Compare this instance to another Duration
      Overrides:
        `equals` in class `Object`
      Returns:
        true if they are equal, false otherwise

    - #### hashCode

          public int hashCode()

      Get the hash code for this instance
      Overrides:
        `hashCode` in class `Object`

Copyright © 2022 VersionOne, Inc.. All rights reserved.