diff --git a/backend/framework/sdk/src/main/java/io/metersphere/sdk/util/ShareUtil.java b/backend/framework/sdk/src/main/java/io/metersphere/sdk/util/ShareUtil.java index d229ce6ac7..218fa2c40d 100644 --- a/backend/framework/sdk/src/main/java/io/metersphere/sdk/util/ShareUtil.java +++ b/backend/framework/sdk/src/main/java/io/metersphere/sdk/util/ShareUtil.java @@ -3,7 +3,6 @@ package io.metersphere.sdk.util; import org.apache.commons.lang3.StringUtils; import java.time.Instant; -import java.time.LocalDate; import java.time.LocalDateTime; import java.time.ZoneId; @@ -50,8 +49,8 @@ public class ShareUtil { } public static long getCleanDate(String expr) { - LocalDate date = null; - LocalDate localDate = LocalDate.now(); + LocalDateTime date = null; + LocalDateTime localDate = LocalDateTime.now(); long timeMills = 0; if (StringUtils.isNotBlank(expr)) { try { @@ -63,6 +62,8 @@ public class ShareUtil { date = localDate.minusMonths(quantity); } else if (StringUtils.equals(unit, UNIT_YEAR)) { date = localDate.minusYears(quantity); + } else if (StringUtils.equals(unit, UNIT_HOUR)) { + date = localDate.minusHours(quantity); } else { LogUtils.error("clean up expr parse error. expr : " + expr); } @@ -72,7 +73,7 @@ public class ShareUtil { } } if (date != null) { - timeMills = date.atStartOfDay(ZoneId.systemDefault()).toInstant().toEpochMilli(); + timeMills = date.atZone(ZoneId.systemDefault()).toInstant().toEpochMilli(); } return timeMills; }