This library contains some helpful utilities for asynchronous tasks, char/number randomization and date/time formatting.
repositories {
maven("https://jitpack.io")
}
dependencies {
implementation("com.github.t0mse:utilities:1.1.2")
}<repositories>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>
<dependency>
<groupId>com.github.t0mse</groupId>
<artifactId>utilities</artifactId>
<version>1.1.2</version>
</dependency>A simple asynchronous countdown that counts down the specified ticks in the specified time unit and automatically stops
when hitting (works with Scheduler)
Located at: de.tomse.misc.utilities.async.Countdown
Click to view
Countdown countdown = new Countdown(5, TimeUnit.SECONDS) {
@Override
public void onTick(int tick) {
// Countdown ticking
}
@Override
public void onLastTick() {
// Countdown finished, stops and resets automatically
}
};countdown.start();countdown.pause();countdown.stop();A builder and holder class to set up, store and manage ScheduledExecutorServices
Located at: de.tomse.misc.utilities.async.Scheduler
Click to view
Scheduler scheduler = Scheduler.runTask(() -> {
// Do something here
});Scheduler scheduler = Scheduler.runTaskLater(() -> {
// Do something here
}, 5, TimeUnit.SECONDS);Scheduler scheduler = Scheduler.repeatingTask(() -> {
// Do something here
}, 5, TimeUnit.SECONDS);Scheduler scheduler = Scheduler.delayedRepeatingTask(() -> {
// Do something here
}, 10, 5, TimeUnit.SECONDS);scheduler.shutdown();A builder class designed to format a given millisecond timestamp to a readable string with the formatted date timestamp
in a specific date format.
Located at: de.tomse.misc.utilities.formatter.DateFormatter
Click to view
| Enum Type | Date Format | Example Output |
|---|---|---|
TIME |
HH:mm:ss |
11:05:09 |
YEAR |
yyyy |
2026 |
DATE |
yyyy-MM-dd |
2026-07-23 |
DATE_YEAR_MONTH |
yyyy-MM |
2026-07 |
EUROPEAN_DATE |
dd.MM.yyyy |
23.07.2026 |
DATE_TIME |
MMM dd yyyy HH:mm:ss |
Jul 23 2026 11:05:09 |
EUROPEAN_DATETIME |
dd.MM.yyyy HH:mm:ss |
23.07.2026 11:05:09 |
LONG_DATE |
MMMM dd yyyy |
July 23 2026 |
FULL_DATE |
EEEE, MMMM dd yyyy |
Thursday, July 23 2026 |
FULL_MONTH_YEAR |
MMMM yyyy |
July 2026 |
LOG |
yyyy-MM-dd HH:mm:ss |
2026-07-23 11:05:09 |
LOG_WITH_MILLIS |
yyyy-MM-dd HH:mm:ss.SSS |
2026-07-23 11:05:09.123 |
RFC_1123 |
EEE, dd MMM yyyy HH:mm:ss zzz |
Thu, 23 Jul 2026 11:05:09 CEST |
UNIX_SECONDS |
yyyy-MM-dd'T'HH:mm:ss |
2026-07-23T14:05:09 |
ISO_8601 |
yyyy-MM-dd'T'HH:mm:ss'Z' |
2026-07-23T14:05:09Z |
ISO_8601_WITH_MILLIS |
yyyy-MM-dd'T'HH:mm:ss.SSS'Z' |
2026-07-23T14:05:09.123Z |
ISO_8601_WITH_OFFSET |
yyyy-MM-dd'T'HH:mm:ssXXX |
2026-07-23T14:05:09+02:00 |
ISO_8601_WITH_MILLIS_OFFSET |
yyyy-MM-dd'T'HH:mm:ss.SSSXXX |
2026-07-23T14:05:09.123+02:00 |
Click to view
DateFormatter dateFormatter = new DateFormatter();// Current date
DateFormatter dateFormatter = new DateFormatter(DateFormatPreset.RFC);
// Specified timestamp
DateFormatter dateFormatter = new DateFormatter(DateFormatPreset.RFC, 133742067L);// Current date
DateFormatter dateFormatter = new DateFormatter("MMM dd yyyy, HH:mm:ss");
// Specified timestamp
DateFormatter dateFormatter = new DateFormatter("MMM dd yyyy, HH:mm:ss", 133742067L);dateFormatter.timeZone("Europe/Berlin");dateFormatter.consumeDateFormat(dateFormat -> {
// Modify dateFormat
});String formattedDate = dateFormatter.format();A builder class designed to format a given millisecond time value to a readable string with the formatted timestamp.
Located at: de.tomse.misc.utilities.formatter.TimeFormatter
Click to view
long timeMillis = 1784719985092L + TimeUnit.DAYS.toMillis(7);
new TimeFormatter(timeMillis)
.displayTimeUnits(TimeUnit.DAYS, TimeUnit.HOURS, TimeUnit.MINUTES)
.onlyDisplayBiggest(true) /* Only display the biggest formatted unit */
.subtractCurrentMillis(true) /* Subtract current time millis from specified time millis*/
.formatSeparator(" - ") /* Separator between formatted units */
.fullUnitNames(false) /* Example: 'd' <-> 'days' */
.hideNullValues(true) /* Hide null values of formatted units */;
.format(); // Format resultA builder class designed to generate/draw a random string outcome of a specified CharSet and length.
Located at: de.tomse.misc.utilities.randomizer.ChatRandomizer
Click to view
| Enum Type | Characters | Description |
|---|---|---|
ALPHA |
ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz |
Only letters |
ALPHANUMERIC |
ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789 |
Only letters and numbers |
NUMERIC |
0123456789 |
Only numbers |
Click to view
String randomAlpha = new CharRandomizer(CharRandomizer.CharSet.ALPHA, 16).draw();
String randomAlphanumeric = new CharRandomizer(CharRandomizer.CharSet.ALPHANUMERIC, 32).draw();
String numeric = new CharRandomizer(CharRandomizer.CharSet.NUMERIC, 8).draw();A builder class designed to generate/draw a random number between a specified range.
Located
at: de.tomse.misc.utilities.randomizer.NumberRandomizer
Click to view
int smallRandomNumber = new NumberRandomizer(1,10).draw();
int mediumRandomNumber = new NumberRandomizer(1_000,10_000).draw();
int largeRandomNumber = new NumberRandomizer(100_000,1_000_000).draw();