src/main/java/com/hx/util/DateUtil.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 |
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()); } }