Package discord4j.common.util
Enum Class TimestampFormat
- All Implemented Interfaces:
Serializable
,Comparable<TimestampFormat>
,Constable
A utility class for formatting a Java
Instant
as a timestamp in Discord messages.- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Enum
Enum.EnumDesc<E extends Enum<E>>
-
Enum Constant Summary
Enum ConstantDescriptionExample:20 April 2021 16:20
Example:20 April 2021
Example:Tuesday, 20 April 2021 16:20
Example:16:20:30
Example:2 months ago
Example:20/04/2021
Example:20 April 2021 16:20
Example:16:20
-
Method Summary
Modifier and TypeMethodDescriptionGets the markdown representation of the providedInstant
for this style.getStyle()
Get the style (1 character) for this timestamp format.static TimestampFormat
Returns the enum constant of this class with the specified name.static TimestampFormat[]
values()
Returns an array containing the constants of this enum class, in the order they are declared.
-
Enum Constant Details
-
DEFAULT
Example:20 April 2021 16:20
-
SHORT_TIME
Example:16:20
-
LONG_TIME
Example:16:20:30
-
SHORT_DATE
Example:20/04/2021
-
LONG_DATE
Example:20 April 2021
-
SHORT_DATE_TIME
Example:20 April 2021 16:20
-
LONG_DATE_TIME
Example:Tuesday, 20 April 2021 16:20
-
RELATIVE_TIME
Example:2 months ago
-
-
Method Details
-
values
Returns an array containing the constants of this enum class, in the order they are declared.- Returns:
- an array containing the constants of this enum class, in the order they are declared
-
valueOf
Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)- Parameters:
name
- the name of the enum constant to be returned.- Returns:
- the enum constant with the specified name
- Throws:
IllegalArgumentException
- if this enum class has no constant with the specified nameNullPointerException
- if the argument is null
-
getStyle
Get the style (1 character) for this timestamp format. The default format returns an empty string.- Returns:
- The style character as a
String
-
format
Gets the markdown representation of the providedInstant
for this style. In a message, Discord will display the timestamp in the user's local timezone.- Parameters:
instant
- theInstant
to construct a timestamp with.- Returns:
- The markdown representation of the
Instant
as a String.
-