瀏覽代碼

时间转换

Administrator 4 年之前
父節點
當前提交
b1ce1b8d95

+ 11 - 0
boman-common/boman-common-core/src/main/java/com/boman/common/core/utils/DateUtils.java

@@ -140,6 +140,7 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils {
 
     /**
      * 获取两个日期之间所有日期
+     *
      * @param startDate
      * @param endDate
      * @return
@@ -148,4 +149,14 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils {
         long numOfDaysBetween = ChronoUnit.DAYS.between(startDate, endDate) + 1;
         return IntStream.iterate(0, i -> i + 1).limit(numOfDaysBetween).mapToObj(startDate::plusDays).collect(Collectors.toList());
     }
+
+    /**
+     * 时间戳转换日期
+     *
+     * @param stamp
+     * @return
+     */
+    public static String stampToTime(String stamp) {
+        return new SimpleDateFormat("yyyy-MM-dd").format(new Date(Long.parseLong(stamp)));
+    }
 }

+ 2 - 2
boman-modules/boman-system/src/main/java/com/boman/system/service/impl/SysScheduleServiceImpl.java

@@ -42,10 +42,10 @@ public class SysScheduleServiceImpl implements ISysScheduleService {
             for (Map.Entry<String, Object> entry : entries) {
                 String key = entry.getKey();
                 if ("begin_time".equals(key)) {
-                    beginTime = LocalDate.parse(String.valueOf(entry.getValue()), formatter);
+                    beginTime = LocalDate.parse(DateUtils.stampToTime(entry.getValue().toString()), formatter);
                     num++;
                 } else if ("end_time".equals(key)) {
-                    endTime = LocalDate.parse(String.valueOf(entry.getValue()), formatter);
+                    endTime = LocalDate.parse(DateUtils.stampToTime(entry.getValue().toString()), formatter);
                     num++;
                 } else if (num == 2) {
                     if (beginTime != null && endTime != null) {