-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added UTC TimeZone and Duration Comparison to DateVersionCommand and …
…updated the Format of the printed DateTime Also added the Build Time to the ChangelogCommand and refactored the code a bit
- Loading branch information
1 parent
1691cd4
commit 6099bc7
Showing
4 changed files
with
107 additions
and
26 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
34 changes: 34 additions & 0 deletions
34
bot/src/main/java/com/almightyalpaca/discord/jdabutler/util/DateUtils.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,34 @@ | ||
package com.almightyalpaca.discord.jdabutler.util; | ||
|
||
import java.time.ZoneId; | ||
import java.time.format.DateTimeFormatter; | ||
|
||
import com.almightyalpaca.discord.jdabutler.Bot; | ||
import com.kantenkugel.discordbot.jenkinsutil.JenkinsApi; | ||
|
||
public final class DateUtils | ||
{ | ||
private static final String DATE_FORMAT = "dd/MM/yyyy 'at' HH:mm:ss"; | ||
public static final JenkinsApi JENKINS = JenkinsApi.JDA_JENKINS; | ||
public static final DateTimeFormatter FORMATTER = getDateTimeFormatter(); | ||
|
||
public static DateTimeFormatter getDateTimeFormatter() { | ||
DateTimeFormatter formatter; | ||
try | ||
{ | ||
formatter = DateTimeFormatter.ofPattern(DATE_FORMAT + " (z)"); | ||
} | ||
catch (NullPointerException | IllegalArgumentException ex) | ||
{ | ||
final String defaultFormat = "dd.MM.yyyy 'at' HH:mm:ss (z)"; | ||
Bot.LOG.warn("Given format for DateVersionCommand was not valid, using: " + defaultFormat); | ||
formatter = DateTimeFormatter.ofPattern(defaultFormat); | ||
} | ||
|
||
return formatter.withZone(ZoneId.of("UTC")); | ||
} | ||
|
||
// prevent instantiation | ||
private DateUtils() {} | ||
|
||
} |
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