public class MiscUtil
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static long |
DISCORD_EPOCH |
static long |
TIMESTAMP_OFFSET |
Constructor and Description |
---|
MiscUtil() |
Modifier and Type | Method and Description |
---|---|
static void |
appendTo(java.util.Formatter formatter,
int width,
int precision,
boolean leftJustified,
java.lang.String out)
Can be used to append a String to a formatter.
|
static okhttp3.RequestBody |
createRequestBody(okhttp3.MediaType contentType,
java.io.InputStream stream)
Creates a new request body that transmits the provided
InputStream . |
static java.lang.String |
encodeUTF8(java.lang.String chars)
URL-Encodes the given String to UTF-8 after
form-data specifications (space -> +)
|
static java.time.OffsetDateTime |
getCreationTime(ISnowflake entity)
Gets the creation-time of a JDA-entity by doing the reverse snowflake algorithm on its id.
|
static java.time.OffsetDateTime |
getCreationTime(long entityId)
Gets the creation-time of a JDA-entity by doing the reverse snowflake algorithm on its id.
|
static java.lang.String |
getDateTimeString(java.time.OffsetDateTime time)
Returns a prettier String-representation of a OffsetDateTime object
|
static <T> gnu.trove.map.TLongObjectMap<T> |
newLongMap()
Generates a new thread-safe
TLongObjectMap |
static long |
parseSnowflake(java.lang.String input) |
public static final long DISCORD_EPOCH
public static final long TIMESTAMP_OFFSET
public static java.time.OffsetDateTime getCreationTime(long entityId)
entityId
- The id of the JDA entity where the creation-time should be determined forpublic static java.time.OffsetDateTime getCreationTime(ISnowflake entity)
entity
- The JDA entity where the creation-time should be determined forjava.lang.IllegalArgumentException
- If the provided entity is null
public static java.lang.String getDateTimeString(java.time.OffsetDateTime time)
time
- The OffsetDateTime object to formatpublic static <T> gnu.trove.map.TLongObjectMap<T> newLongMap()
TLongObjectMap
T
- The Object typeTLongObjectMap
public static java.lang.String encodeUTF8(java.lang.String chars)
chars
- The characters to encodepublic static long parseSnowflake(java.lang.String input)
public static void appendTo(java.util.Formatter formatter, int width, int precision, boolean leftJustified, java.lang.String out)
formatter
- The Formatter
width
- Minimum width to meet, filled with space if neededprecision
- Maximum amount of characters to appendleftJustified
- Whether or not to left-justify the valueout
- The String to appendpublic static okhttp3.RequestBody createRequestBody(okhttp3.MediaType contentType, java.io.InputStream stream)
InputStream
.contentType
- The MediaType
of the datastream
- The InputStream
to be transmitted