Package ch.njol.skript.util
Class Timespan
java.lang.Object
ch.njol.skript.util.Timespan
- All Implemented Interfaces:
YggdrasilSerializable
,Comparable<Timespan>
,TemporalAmount
public class Timespan
extends Object
implements YggdrasilSerializable, Comparable<Timespan>, TemporalAmount
Represents a duration of time, such as 2 days, similar to
Duration
.-
Nested Class Summary
Nested classes/interfaces inherited from interface ch.njol.yggdrasil.YggdrasilSerializable
YggdrasilSerializable.YggdrasilExtendedSerializable, YggdrasilSerializable.YggdrasilRobustEnum, YggdrasilSerializable.YggdrasilRobustSerializable
-
Constructor Summary
ConstructorDescriptionTimespan()
Timespan
(long millis) Builds a Timespan from the given milliseconds.Timespan
(Timespan.TimePeriod timePeriod, long time) Builds a Timespan from the given long parameter of a specificTimespan.TimePeriod
. -
Method Summary
Modifier and TypeMethodDescriptionint
boolean
static Timespan
fromDuration
(Duration duration) static Timespan
fromTicks
(long ticks) Deprecated, for removal: This API element is subject to removal in a future version.static Timespan
fromTicks_i
(long ticks) Deprecated, for removal: This API element is subject to removal in a future version.UseTimespan(TimePeriod, long)
instead.long
get
(TemporalUnit unit) long
getAs
(Timespan.TimePeriod timePeriod) long
Deprecated, for removal: This API element is subject to removal in a future version.long
getTicks()
Deprecated, for removal: This API element is subject to removal in a future version.long
Deprecated, for removal: This API element is subject to removal in a future version.getUnits()
int
hashCode()
static @Nullable Timespan
static @Nullable Timespan
parse
(String value, ParseContext context) subtractFrom
(Temporal temporal) toString()
toString
(int flags) static String
toString
(long millis) static String
toString
(long millis, int flags)
-
Constructor Details
-
Timespan
public Timespan() -
Timespan
public Timespan(long millis) Builds a Timespan from the given milliseconds.- Parameters:
millis
- The milliseconds of Timespan
-
Timespan
Builds a Timespan from the given long parameter of a specificTimespan.TimePeriod
.- Parameters:
timePeriod
- The requested TimePeriodtime
- The time of the requested TimePeriod
-
-
Method Details
-
parse
-
parse
-
fromDuration
-
toString
-
toString
-
fromTicks
Deprecated, for removal: This API element is subject to removal in a future version. -
fromTicks_i
Deprecated, for removal: This API element is subject to removal in a future version.UseTimespan(TimePeriod, long)
instead. -
getMilliSeconds
Deprecated, for removal: This API element is subject to removal in a future version. -
getTicks
Deprecated, for removal: This API element is subject to removal in a future version. -
getTicks_i
Deprecated, for removal: This API element is subject to removal in a future version. -
getAs
- Returns:
- the amount of TimePeriod this timespan represents.
-
getDuration
- Returns:
- Converts this timespan to a
Duration
.
-
get
- Specified by:
get
in interfaceTemporalAmount
-
getUnits
- Specified by:
getUnits
in interfaceTemporalAmount
-
addTo
- Specified by:
addTo
in interfaceTemporalAmount
-
subtractFrom
- Specified by:
subtractFrom
in interfaceTemporalAmount
-
compareTo
- Specified by:
compareTo
in interfaceComparable<Timespan>
-
hashCode
public int hashCode() -
equals
-
toString
-
toString
-
Timespan(TimePeriod, long)