Package net.dv8tion.jda.api.utils
Class Timestamp
java.lang.Object
net.dv8tion.jda.api.utils.Timestamp
Utility class representing Discord Markdown timestamps.
This class implements
This class implements
toString()
such that it can be directly included in message content.
These timestamps are rendered by the individual receiving Discord client in a local timezone and language format.
Each timestamp can be displayed with different TimeFormats
.
-
Method Summary
Modifier and TypeMethodDescriptionTheTimeFormat
used to display this timestamp.long
The unix epoch timestamp for this markdown timestamp.minus
(long millis) Creates a new timestamp instance with the provided offset into the past relative to the current timestamp.Creates a new timestamp instance with the provided offset into the past relative to the current timestamp.plus
(long millis) Creates a new timestamp instance with the provided offset into the future relative to the current timestamp.Creates a new timestamp instance with the provided offset into the future relative to the current timestamp.Shortcut forInstant.ofEpochMilli(getTimestamp())
.toString()
-
Method Details
-
getFormat
TheTimeFormat
used to display this timestamp.- Returns:
- The
TimeFormat
-
getTimestamp
public long getTimestamp()The unix epoch timestamp for this markdown timestamp.
This is similar toSystem.currentTimeMillis()
and provided in millisecond precision for easier compatibility. Discord uses seconds precision instead.- Returns:
- The millisecond unix epoch timestamp
-
toInstant
Shortcut forInstant.ofEpochMilli(getTimestamp())
.- Returns:
- The
Instant
of this timestamp
-
plus
Creates a new timestamp instance with the provided offset into the future relative to the current timestamp.- Parameters:
millis
- The millisecond offset for the new timestamp- Returns:
- Copy of this timestamp with the relative offset
- See Also:
-
plus
Creates a new timestamp instance with the provided offset into the future relative to the current timestamp.- Parameters:
duration
- The offset for the new timestamp- Returns:
- Copy of this timestamp with the relative offset
- Throws:
IllegalArgumentException
- If the provided duration is null- See Also:
-
minus
Creates a new timestamp instance with the provided offset into the past relative to the current timestamp.- Parameters:
millis
- The millisecond offset for the new timestamp- Returns:
- Copy of this timestamp with the relative offset
- See Also:
-
minus
Creates a new timestamp instance with the provided offset into the past relative to the current timestamp.- Parameters:
duration
- The offset for the new timestamp- Returns:
- Copy of this timestamp with the relative offset
- Throws:
IllegalArgumentException
- If the provided duration is null- See Also:
-
toString
-