-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
32f41d3
commit 42f9bd1
Showing
6 changed files
with
38 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
src/main/java/net/sacredlabyrinth/phaed/simpleclans/utils/DateFormat.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package net.sacredlabyrinth.phaed.simpleclans.utils; | ||
|
||
import net.sacredlabyrinth.phaed.simpleclans.SimpleClans; | ||
|
||
import java.text.SimpleDateFormat; | ||
import java.util.Date; | ||
|
||
import static net.sacredlabyrinth.phaed.simpleclans.managers.SettingsManager.ConfigField.DATE_TIME_PATTERN; | ||
|
||
public class DateFormat { | ||
|
||
private static final SimpleClans plugin = SimpleClans.getInstance(); | ||
private static SimpleDateFormat format; | ||
|
||
static { | ||
String pattern = plugin.getSettingsManager().getString(DATE_TIME_PATTERN); | ||
try { | ||
format = new SimpleDateFormat(pattern); | ||
} catch (IllegalArgumentException ex) { | ||
plugin.getLogger().warning("%s is not a valid pattern!".formatted(pattern)); | ||
format = new SimpleDateFormat("HH:mm - dd/MM/yyyy"); | ||
} | ||
} | ||
|
||
public static String formatDateTime(long date) { | ||
return format.format(new Date(date)); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters