Skip to content

Commit e4b2623

Browse files
committed
Fix exception when parsing dates with no times
Otherwise, `parseInt` throws because it is passed `null`.
1 parent 386e273 commit e4b2623

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/main/java/dev/qixils/quasicord/converter/impl/ZonedDateTimeConverter.java

+4-2
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,10 @@ public ZonedDateTimeConverter(@NonNull Quasicord library) {
9494
// get time
9595
Matcher timeMatcher = TIME_PATTERN.matcher(input);
9696
if (timeMatcher.find()) {
97-
hour = Integer.parseInt(timeMatcher.group("hour"));
98-
minute = Integer.parseInt(timeMatcher.group("minute"));
97+
if (timeMatcher.group("hour") != null)
98+
hour = Integer.parseInt(timeMatcher.group("hour"));
99+
if (timeMatcher.group("minute") != null)
100+
minute = Integer.parseInt(timeMatcher.group("minute"));
99101
if (timeMatcher.group("second") != null)
100102
second = Integer.parseInt(timeMatcher.group("second"));
101103
if (timeMatcher.group("nanos") != null)

0 commit comments

Comments
 (0)