Package net.dv8tion.jda.api.utils
Class TimeUtil
java.lang.Object
net.dv8tion.jda.api.utils.TimeUtil
Utility for various time related features of the API.
- 
Field SummaryFieldsModifier and TypeFieldDescriptionstatic final longstatic final long
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionstatic StringReturns a prettier String-representation of a OffsetDateTime objectstatic longgetDiscordTimestamp(long millisTimestamp) Converts the provided epoch millisecond timestamp to a Discord Snowflake.static OffsetDateTimegetTimeCreated(long entityId) Gets the creation-time of a JDA-entity by doing the reverse snowflake algorithm on its id.static OffsetDateTimegetTimeCreated(ISnowflake entity) Gets the creation-time of a JDA-entity by doing the reverse snowflake algorithm on its id.
- 
Field Details- 
DISCORD_EPOCHpublic static final long DISCORD_EPOCH- See Also:
 
- 
TIMESTAMP_OFFSETpublic static final long TIMESTAMP_OFFSET- See Also:
 
 
- 
- 
Constructor Details- 
TimeUtilpublic TimeUtil()
 
- 
- 
Method Details- 
getDiscordTimestamppublic static long getDiscordTimestamp(long millisTimestamp) Converts the provided epoch millisecond timestamp to a Discord Snowflake.
 This can be used as a marker/pivot forMessageHistorycreation.- Parameters:
- millisTimestamp- The epoch millis to convert
- Returns:
- Shifted epoch millis for Discord
 
- 
getTimeCreatedGets the creation-time of a JDA-entity by doing the reverse snowflake algorithm on its id. This returns the creation-time of the actual entity on Discords side, not inside JDA.- Parameters:
- entityId- The id of the JDA entity where the creation-time should be determined for
- Returns:
- The creation time of the JDA entity as OffsetDateTime
 
- 
getTimeCreatedGets the creation-time of a JDA-entity by doing the reverse snowflake algorithm on its id. This returns the creation-time of the actual entity on Discords side, not inside JDA.- Parameters:
- entity- The JDA entity where the creation-time should be determined for
- Returns:
- The creation time of the JDA entity as OffsetDateTime
- Throws:
- IllegalArgumentException- If the provided entity is- null
 
- 
getDateTimeStringReturns a prettier String-representation of a OffsetDateTime object- Parameters:
- time- The OffsetDateTime object to format
- Returns:
- The String of the formatted OffsetDateTime
 
 
-