Package net.dv8tion.jda.api.entities
Class Activity.Timestamps
- java.lang.Object
-
- net.dv8tion.jda.api.entities.Activity.Timestamps
-
- Enclosing interface:
- Activity
public static class Activity.Timestamps extends java.lang.ObjectRepresents the start and end timestamps for a running match
-
-
Constructor Summary
Constructors Constructor Description Timestamps(long start, long end)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanequals(java.lang.Object obj)longgetElapsedTime(java.time.temporal.TemporalUnit unit)Calculates the elapsed time fromgetStartTime()to now in terms of the specified unit.longgetEnd()Epoch second timestamp of match end, or0of unset.java.time.InstantgetEndTime()Shortcut forInstant.ofEpochSecond(start)longgetRemainingTime(java.time.temporal.TemporalUnit unit)Calculates the amount of time untilgetEndTime()in terms of the specified unit.longgetStart()Epoch second timestamp of match start, or0of unset.java.time.InstantgetStartTime()Shortcut forInstant.ofEpochSecond(start)inthashCode()java.lang.StringtoString()
-
-
-
Method Detail
-
getStart
public long getStart()
Epoch second timestamp of match start, or0of unset.- Returns:
- Epoch second timestamp of match start, or
0of unset.
-
getStartTime
@Nullable public java.time.Instant getStartTime()
Shortcut forInstant.ofEpochSecond(start)- Returns:
- Instant of match start, or
nullif unset
-
getEnd
public long getEnd()
Epoch second timestamp of match end, or0of unset.- Returns:
- Epoch second timestamp of match end, or
0of unset.
-
getEndTime
@Nullable public java.time.Instant getEndTime()
Shortcut forInstant.ofEpochSecond(start)- Returns:
- Instant of match start, or
nullif unset
-
getRemainingTime
public long getRemainingTime(java.time.temporal.TemporalUnit unit)
Calculates the amount of time untilgetEndTime()in terms of the specified unit.
IfgetEndTime()isnullthis will be negative.- Parameters:
unit- TheTemporalUnitto return- Returns:
- Remaining time in the provided
TemporalUnitor-1if unset - Throws:
java.lang.IllegalArgumentException- If the provided unit isnulljava.lang.ArithmeticException- If a numeric overflow occursjava.time.DateTimeException- If the amount cannot be calculatedjava.time.temporal.UnsupportedTemporalTypeException- If the provided unit is not supported- See Also:
Instant.until(Temporal, TemporalUnit),TemporalUnit
-
getElapsedTime
public long getElapsedTime(java.time.temporal.TemporalUnit unit)
Calculates the elapsed time fromgetStartTime()to now in terms of the specified unit.
IfgetStartTime()isnullthis will be negative.- Parameters:
unit- TheTemporalUnitto return- Returns:
- Elapsed time in the provided
TemporalUnitor-1if unset - Throws:
java.lang.IllegalArgumentException- If the provided unit isnulljava.lang.ArithmeticException- If a numeric overflow occursjava.time.DateTimeException- If the amount cannot be calculatedjava.time.temporal.UnsupportedTemporalTypeException- If the provided unit is not supported- See Also:
Instant.until(Temporal, TemporalUnit),TemporalUnit
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equalsin classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
-