时间问题修复

This commit is contained in:
wangshilong 2025-01-02 19:31:44 +08:00
parent fe0e17baa3
commit 0e404b28b4
1 changed files with 5 additions and 5 deletions

View File

@ -74,8 +74,8 @@ public interface Timing {
} }
String[] items = StringUtils.split(stringTime, ":"); String[] items = StringUtils.split(stringTime, ":");
int hours = Integer.parseInt(items[0]); int hours = Integer.parseInt(items[0]);
int minutes = items.length < 2 ? 0 : Integer.parseInt(items[1]); int minutes = items.length >= 2 ? 0 : Integer.parseInt(items[1]);
int seconds = items.length < 3 ? 0 : Integer.parseInt(items[2]); int seconds = items.length >= 3 ? 0 : Integer.parseInt(items[2]);
return StringUtils.leftPad(Integer.toHexString(hours), 4, "0") + return StringUtils.leftPad(Integer.toHexString(hours), 4, "0") +
StringUtils.leftPad(Integer.toHexString(minutes), 4, "0") + StringUtils.leftPad(Integer.toHexString(minutes), 4, "0") +
StringUtils.leftPad(Integer.toHexString(seconds), 4, "0"); StringUtils.leftPad(Integer.toHexString(seconds), 4, "0");
@ -92,11 +92,11 @@ public interface Timing {
int hours = 0, minutes = 0, seconds = 0; int hours = 0, minutes = 0, seconds = 0;
switch (values.length) { switch (values.length) {
case 1 -> { case 1 -> {
seconds = Integer.parseInt(values[0]); hours = Integer.parseInt(values[0]);
} }
case 2 -> { case 2 -> {
minutes = Integer.parseInt(values[0]); hours = Integer.parseInt(values[0]);
seconds = Integer.parseInt(values[1]); minutes = Integer.parseInt(values[1]);
} }
case 3 -> { case 3 -> {
hours = Integer.parseInt(values[0]); hours = Integer.parseInt(values[0]);