Enum TimeFormat

java.lang.Object
java.lang.Enum<TimeFormat>
net.dv8tion.jda.api.utils.TimeFormat
All Implemented Interfaces:
Serializable, Comparable<TimeFormat>

public enum TimeFormat extends Enum<TimeFormat>
Utility enum used to provide different markdown styles for timestamps.
These can be used to represent a unix epoch timestamp in different formats.

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.

Example


 channel.sendMessage("Current Time: " + TimeFormat.RELATIVE.now()).queue();
 channel.sendMessage("Uptime: " + TimeFormat.RELATIVE.format(getStartTime())).queue();
 
  • Enum Constant Details

    • TIME_SHORT

      public static final TimeFormat TIME_SHORT
      Formats time as 18:49 or 6:49 PM
    • TIME_LONG

      public static final TimeFormat TIME_LONG
      Formats time as 18:49:26 or 6:49:26 PM
    • DATE_SHORT

      public static final TimeFormat DATE_SHORT
      Formats date as 16/06/2021 or 06/16/2021
    • DATE_LONG

      public static final TimeFormat DATE_LONG
      Formats date as 16 June 2021
    • DATE_TIME_SHORT

      public static final TimeFormat DATE_TIME_SHORT
      Formats date and time as 16 June 2021 18:49 or June 16, 2021 6:49 PM
    • DATE_TIME_LONG

      public static final TimeFormat DATE_TIME_LONG
      Formats date and time as Wednesday, 16 June 2021 18:49 or Wednesday, June 16, 2021 6:49 PM
    • RELATIVE

      public static final TimeFormat RELATIVE
      Formats date and time as relative 18 minutes ago or 2 days ago
  • Field Details

    • DEFAULT

      public static final TimeFormat DEFAULT
      The default time format used when no style is provided.
    • MARKDOWN

      public static final Pattern MARKDOWN
      Pattern used for parse(String).

      Groups

      Javadoc is stupid, this is not a required tag
      Index Name Description
      0 N/A The entire timestamp markdown
      1 time The timestamp value as a unix epoch in second precision
      2 style The style used for displaying the timestamp (single letter flag)
      See Also:
  • Method Details