public class TimeInterval extends java.lang.Object implements java.lang.Comparable<TimeInterval>
TimeUnit
.
The class also provides methods of retrieval of its value as a long in needed scale (nanoseconds, milliseconds,
seconds, minutes, hours or days) see methods toNanos()
, toMillis()
, toSeconds()
,
toMinutes()
, toHours()
, toDays()
Constructor and Description |
---|
TimeInterval()
Default constructor
|
TimeInterval(long interval,
java.util.concurrent.TimeUnit timeUnit)
Constructor that allows to create initialized instance
|
Modifier and Type | Method and Description |
---|---|
int |
compareTo(TimeInterval o) |
boolean |
equals(java.lang.Object o) |
java.util.concurrent.TimeUnit |
getTimeUnit()
TimeUnit getter |
long |
getValue()
Time interval numerical value getter (without time unit)
|
int |
hashCode() |
void |
setTimeUnit(java.util.concurrent.TimeUnit timeUnit)
TimeUnit Setter
|
void |
setValue(long value)
Numerical value setter
|
long |
toDays()
returns long value of this TimeInterval in days
|
long |
toHours()
returns long value of this TimeInterval in hours
|
long |
toMillis()
returns long value of this TimeInterval in milliseconds
|
long |
toMinutes()
returns long value of this TimeInterval in minutes
|
long |
toNanos()
returns long value of this TimeInterval in nanoseconds
|
long |
toSeconds()
returns long value of this TimeInterval in seconds
|
java.lang.String |
toString()
Provides String representation of the value such as "3 MILLISECONDS".
|
public TimeInterval()
public TimeInterval(long interval, java.util.concurrent.TimeUnit timeUnit)
interval
- time valuetimeUnit
- TimeUnit that defines scalepublic long getValue()
public void setValue(long value)
value
- public java.util.concurrent.TimeUnit getTimeUnit()
TimeUnit
getterTimeUnit
of this TimeIntervalpublic void setTimeUnit(java.util.concurrent.TimeUnit timeUnit)
timeUnit
- public long toNanos()
public long toMillis()
public long toSeconds()
public long toMinutes()
public long toHours()
public long toDays()
public java.lang.String toString()
toString
in class java.lang.Object
public int compareTo(TimeInterval o)
compareTo
in interface java.lang.Comparable<TimeInterval>
public boolean equals(java.lang.Object o)
equals
in class java.lang.Object
public int hashCode()
hashCode
in class java.lang.Object