Class Duration

  • All Implemented Interfaces:
    java.io.Serializable

    public class Duration
    extends java.lang.Object
    implements java.io.Serializable
    Since:
    4.3
    See Also:
    Serialized Form
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static java.lang.String DAY  
      static java.lang.String HOUR  
      static java.lang.String MINUTE  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      Duration add​(Duration with)
      Add the given duration to the current one.
      static Duration create​(long durationInMinutes)
      Create a Duration from a number of minutes.
      static Duration decode​(java.lang.String text, int hoursInDay)
      Create a Duration from a text duration and the number of hours in a day.
      java.lang.String encode​(int hoursInDay)
      Return the duration in text, by using the given hours in day parameter to process hours.
      boolean equals​(java.lang.Object o)  
      int hashCode()  
      boolean isGreaterThan​(Duration other)
      Return true if the given duration is greater than the current one.
      Duration multiply​(int factor)
      Multiply the duration with the given factor.
      Duration subtract​(Duration with)
      Subtract the given duration to the current one.
      long toMinutes()
      Return the duration in minutes.
      java.lang.String toString()  
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, wait, wait, wait
    • Method Detail

      • create

        public static Duration create​(long durationInMinutes)
        Create a Duration from a number of minutes.
      • decode

        public static Duration decode​(java.lang.String text,
                                      int hoursInDay)
        Create a Duration from a text duration and the number of hours in a day.
        For instance, Duration.decode("1d 1h", 8) will have a number of minutes of 540 (1*8*60 + 60).
      • encode

        public java.lang.String encode​(int hoursInDay)
        Return the duration in text, by using the given hours in day parameter to process hours.
        Duration.decode("1d 1h", 8).encode(8) will return "1d 1h" Duration.decode("2d", 8).encode(16) will return "1d"
      • toMinutes

        public long toMinutes()
        Return the duration in minutes.
        For instance, Duration.decode(1h, 24).toMinutes() will return 60.
      • isGreaterThan

        public boolean isGreaterThan​(Duration other)
        Return true if the given duration is greater than the current one.
      • add

        public Duration add​(Duration with)
        Add the given duration to the current one.
      • subtract

        public Duration subtract​(Duration with)
        Subtract the given duration to the current one.
      • multiply

        public Duration multiply​(int factor)
        Multiply the duration with the given factor.
      • equals

        public boolean equals​(java.lang.Object o)
        Overrides:
        equals in class java.lang.Object
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object