Package ch.njol.skript.util
Class Date
java.lang.Object
java.util.Date
ch.njol.skript.util.Date
- All Implemented Interfaces:
YggdrasilSerializable
,Serializable
,Cloneable
,Comparable<Date>
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from interface ch.njol.yggdrasil.YggdrasilSerializable
YggdrasilSerializable.YggdrasilExtendedSerializable, YggdrasilSerializable.YggdrasilRobustEnum, YggdrasilSerializable.YggdrasilRobustSerializable
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
Add aTimespan
to this datedifference
(Date other) Returns the difference between this date and another date as aTimespan
.boolean
static Date
fromJavaDate
(Date date) long
Deprecated, for removal: This API element is subject to removal in a future version.int
hashCode()
Get a new instance of this Date with the subtracted timespanstatic Date
now()
Get a new Date with the current timeGet a new instance of this Date with the added timespanvoid
Subtract aTimespan
from this datetoString()
Methods inherited from class java.util.Date
after, before, clone, compareTo, from, getDate, getDay, getHours, getMinutes, getMonth, getSeconds, getTime, getTimezoneOffset, getYear, parse, setDate, setHours, setMinutes, setMonth, setSeconds, setTime, setYear, toGMTString, toInstant, toLocaleString, UTC
-
Constructor Details
-
Date
public Date()Creates a new Date with the current time. -
Date
public Date(long timestamp) Creates a new Date with the provided timestamp.- Parameters:
timestamp
- The timestamp in milliseconds.
-
Date
Creates a new Date with the provided timestamp and timezone.- Parameters:
timestamp
- The timestamp in milliseconds.zone
- The timezone to use.
-
-
Method Details
-
now
Get a new Date with the current time- Returns:
- New date with the current time
-
fromJavaDate
- Parameters:
date
- TheDate
to convert.- Returns:
- The converted date.
-
add
Add aTimespan
to this date- Parameters:
other
- Timespan to add
-
subtract
Subtract aTimespan
from this date- Parameters:
other
- Timespan to subtract
-
difference
Returns the difference between this date and another date as aTimespan
.- Parameters:
other
- The other date.- Returns:
- The difference between the provided dates as a
Timespan
.
-
plus
Get a new instance of this Date with the added timespan- Parameters:
other
- Timespan to add to this Date- Returns:
- New Date with the added timespan
-
minus
Get a new instance of this Date with the subtracted timespan- Parameters:
other
- Timespan to subtract from this Date- Returns:
- New Date with the subtracted timespan
-
getTimestamp
Deprecated, for removal: This API element is subject to removal in a future version.UseDate.getTime()
instead. -
hashCode
public int hashCode() -
equals
-
toString
-
Date.getTime()
instead.