| Constructor and Description |
|---|
TimeInterval(int duration,
TimeUnit timeUnit)
Builds a TimeInterval with a given duration and
TimeUnit. |
TimeInterval(TimeInterval source)
Builds a new TimeInterval with the same attributes from a preset object.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
equals(Object obj) |
int |
getDuration()
Returns the duration of this
TimeUnit. |
TimeUnit |
getTimeUnit()
Returns the
TimeUnit associated with this TimeInterval. |
int |
hashCode()
Returns a hash code value for the object, to support hash tables.
|
static TimeInterval |
of(String input)
Builds a TimerInterval by parsing the given string.
|
long |
toMillis()
Returns this time interval's duration, in milliseconds.
|
String |
toString()
Returns a human-friendly string representation of this
TimeInterval, for
example: "2 minute(s)". |
public TimeInterval(int duration,
TimeUnit timeUnit)
TimeUnit.duration - the duration to settimeUnit - the TimeUnit to setpublic TimeInterval(TimeInterval source)
source - the source object to be copied; not nullNullPointerException - if the source TimeInterval is nullpublic static TimeInterval of(String input)
For example: all of the following formats are recognized (case ignored):
input - the string to be parsedIllegalArgumentException - if the string is not in a valid TimeInterval formatpublic int getDuration()
TimeUnit.public TimeUnit getTimeUnit()
TimeUnit associated with this TimeInterval.public long toMillis()
public String toString()
TimeInterval, for
example: "2 minute(s)".toString in class ObjectObject.toString()public int hashCode()
hashCode in class ObjectObject.hashCode()public boolean equals(Object obj)
equals in class ObjectObject.equals(Object)Copyright © 2022. All rights reserved.