Class Duration

java.lang.Object
net.jodah.lyra.util.Duration
All Implemented Interfaces:
java.io.Serializable

public class Duration
extends java.lang.Object
implements java.io.Serializable
Duration unit, consisting of length and time unit.
See Also:
Serialized Form
  • Field Summary

    Fields 
    Modifier and Type Field Description
    boolean finite  
    static Duration INFINITE
    A duration of Long.MAX_VALUE Days
    long length  
    java.util.concurrent.TimeUnit timeUnit  
  • Method Summary

    Modifier and Type Method Description
    static Duration days​(long count)
    Returns a Duration of count days.
    boolean equals​(java.lang.Object obj)  
    int hashCode()  
    static Duration hours​(long count)
    Returns a Duration of count hours.
    static Duration inf()
    Returns an infinite duration of Long.MAX_VALUE days.
    static Duration infinite()
    Returns an infinite duration of Long.MAX_VALUE days.
    static Duration microseconds​(long count)
    Returns a Duration of count microseconds.
    static Duration millis​(long count)
    Returns a Duration of count milliseconds.
    static Duration milliseconds​(long count)
    Returns a Duration of count milliseconds.
    static Duration mins​(long count)
    Returns a Duration of count minutes.
    static Duration minutes​(long count)
    Returns a Duration of count minutes.
    static Duration nanos​(long count)
    Returns a Duration of count nanoseconds.
    static Duration nanoseconds​(long count)
    Returns a Duration of count nanoseconds.
    static Duration of​(long count, java.util.concurrent.TimeUnit unit)
    Returns a Duration of count units.
    static Duration of​(java.lang.String duration)
    Returns a Duration from the parsed duration.
    static Duration seconds​(long count)
    Returns a Duration of count seconds.
    static Duration secs​(long count)
    Returns a Duration of count seconds.
    long toDays()
    Returns the Duration converted to days.
    long toHours()
    Returns the Duration converted to hours.
    long toMicros()
    Returns the Duration converted to microseconds.
    long toMicroseconds()
    Returns the Duration converted to microseconds.
    long toMillis()
    Returns the Duration converted to milliseconds.
    long toMilliseconds()
    Returns the Duration converted to milliseconds.
    long toMins()
    Returns the Duration converted to minutes.
    long toMinutes()
    Returns the Duration converted to minutes.
    long toNanos()
    Returns the Duration converted to nanoseconds.
    long toNanoseconds()
    Returns the Duration converted to nanoseconds.
    long toSeconds()
    Returns the Duration converted to seconds.
    long toSecs()
    Returns the Duration converted to seconds.
    java.lang.String toString()  

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Field Details

    • INFINITE

      public static final Duration INFINITE
      A duration of Long.MAX_VALUE Days
    • length

      public final long length
    • timeUnit

      public final java.util.concurrent.TimeUnit timeUnit
    • finite

      public final boolean finite
  • Method Details

    • equals

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

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

      public long toDays()
      Returns the Duration converted to days.
    • toHours

      public long toHours()
      Returns the Duration converted to hours.
    • toMicros

      public long toMicros()
      Returns the Duration converted to microseconds.
    • toMicroseconds

      public long toMicroseconds()
      Returns the Duration converted to microseconds.
    • toMillis

      public long toMillis()
      Returns the Duration converted to milliseconds.
    • toMilliseconds

      public long toMilliseconds()
      Returns the Duration converted to milliseconds.
    • toMins

      public long toMins()
      Returns the Duration converted to minutes.
    • toMinutes

      public long toMinutes()
      Returns the Duration converted to minutes.
    • toNanos

      public long toNanos()
      Returns the Duration converted to nanoseconds.
    • toNanoseconds

      public long toNanoseconds()
      Returns the Duration converted to nanoseconds.
    • toSeconds

      public long toSeconds()
      Returns the Duration converted to seconds.
    • toSecs

      public long toSecs()
      Returns the Duration converted to seconds.
    • toString

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

      public static Duration days​(long count)
      Returns a Duration of count days.
    • hours

      public static Duration hours​(long count)
      Returns a Duration of count hours.
    • inf

      public static Duration inf()
      Returns an infinite duration of Long.MAX_VALUE days.
    • infinite

      public static Duration infinite()
      Returns an infinite duration of Long.MAX_VALUE days.
    • microseconds

      public static Duration microseconds​(long count)
      Returns a Duration of count microseconds.
    • millis

      public static Duration millis​(long count)
      Returns a Duration of count milliseconds.
    • milliseconds

      public static Duration milliseconds​(long count)
      Returns a Duration of count milliseconds.
    • mins

      public static Duration mins​(long count)
      Returns a Duration of count minutes.
    • minutes

      public static Duration minutes​(long count)
      Returns a Duration of count minutes.
    • nanos

      public static Duration nanos​(long count)
      Returns a Duration of count nanoseconds.
    • nanoseconds

      public static Duration nanoseconds​(long count)
      Returns a Duration of count nanoseconds.
    • of

      public static Duration of​(long count, java.util.concurrent.TimeUnit unit)
      Returns a Duration of count units.
    • of

      public static Duration of​(java.lang.String duration)
      Returns a Duration from the parsed duration. Example:
       5 s
       5 seconds
       10m
       10 minutes
       
    • seconds

      public static Duration seconds​(long count)
      Returns a Duration of count seconds.
    • secs

      public static Duration secs​(long count)
      Returns a Duration of count seconds.