From 8782bcc0f6673c6b8d6e8e26f3032ac458ad7dd0 Mon Sep 17 00:00:00 2001
From: fwq <582742538@qq.com>
Date: 星期一, 26 十二月 2022 16:46:24 +0800
Subject: [PATCH] 时间工具类

---
 src/main/java/com/hx/util/DateUtil.java |   15 +++++++++++++++
 1 files changed, 15 insertions(+), 0 deletions(-)

diff --git a/src/main/java/com/hx/util/DateUtil.java b/src/main/java/com/hx/util/DateUtil.java
index d1e6aab..18bc8ff 100644
--- a/src/main/java/com/hx/util/DateUtil.java
+++ b/src/main/java/com/hx/util/DateUtil.java
@@ -728,4 +728,19 @@
 
         return date.compareTo(cal.getTime()) < 1;
     }
+
+    /**
+     * 鑾峰緱鏌愪釜鏃ユ湡鐨勫綋澶╂煇鐐�
+     * 渚嬪:2022-12-26 11:20:00 -> 2022-12-26 13:00:00
+     * @param num 24灏忔椂
+     */
+    public static String getHourDayTime(Date date,int num) {
+        Calendar calendar = Calendar.getInstance();
+        calendar.setTime(date);
+        calendar.set(Calendar.HOUR_OF_DAY, num);
+        calendar.set(Calendar.MINUTE, 0);
+        calendar.set(Calendar.SECOND, 0);
+        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.CHINA);
+        return sdf.format(calendar.getTime());
+    }
 }

--
Gitblit v1.8.0