From e94e5dbbfc544c558a09fb388e7f4d4341fe8ec4 Mon Sep 17 00:00:00 2001 From: cjl <276999030@qq.com> Date: Thu, 28 Sep 2023 16:59:01 +0800 Subject: [PATCH] ci:添加自有权限 --- screen-common/src/main/java/com/moral/util/DateUtils.java | 59 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 files changed, 58 insertions(+), 1 deletions(-) diff --git a/screen-common/src/main/java/com/moral/util/DateUtils.java b/screen-common/src/main/java/com/moral/util/DateUtils.java index 3699260..5a51ae9 100644 --- a/screen-common/src/main/java/com/moral/util/DateUtils.java +++ b/screen-common/src/main/java/com/moral/util/DateUtils.java @@ -80,6 +80,10 @@ * ������������(yyyy-MM-dd HH) * */ public static final String yyyy_MM_dd_HH_EN = "yyyy-MM-dd HH"; + /* + * ������������(MM-dd) + * */ + public static final String MM_dd_EN = "MM-dd"; /* * Date���toString������ @@ -438,7 +442,7 @@ } /** - * ������������"yyyy-MM-dd HH:mm:ss"������������������������������������������,time2-time1 + * ������������"yyyy-MM-dd"������������������������������������������,time2-time1 * * @param time1 * @param time2 @@ -449,6 +453,20 @@ Date d2 = getDate(time2); return d2.getTime() - d1.getTime(); } + + /** + * ������������"yyyy-MM-dd HH:mm:ss"������������������������������������������,time2-time1 + * + * @param time1 + * @param time2 + * @return + */ + public static long compareDateStrDay(String time1, String time2) { + Date d1 = getDate(time1,DateUtils.yyyy_MM_dd_HH_mm_ss_EN); + Date d2 = getDate(time2,DateUtils.yyyy_MM_dd_HH_mm_ss_EN); + return d2.getTime() - d1.getTime(); + } + /** * ��������������������������������������� @@ -503,6 +521,14 @@ } } + public static boolean isTimeBeforE(Date nows, Date date) { + long hous = nows.getTime() - date.getTime(); + if (hous >= 0) { + return true; + } else { + return false; + } + } /** * ������������������������������������������������������ * @@ -616,6 +642,22 @@ now.setTime(getDate(date, formatStr)); now.add(Calendar.DATE, day); return dateToDateString(now.getTime(), formatStr); + } + + + /** + * ������������������day���������������(formatStr)������������ + * + * @param date + * @param date, + * @param hours + * @return + */ + public static Date getDateAddHour(Date date,int hours) { + Calendar now = Calendar.getInstance(TimeZone.getDefault()); + now.setTime(date); + now.add(Calendar.HOUR_OF_DAY, hours); + return now.getTime(); } /** @@ -1044,6 +1086,14 @@ return getDate(dateToDateString(cal.getTime(), yyyy_MM_dd_EN)); } + public static Date getLastDayOfCurrMonth(Date time) { + Calendar cal = Calendar.getInstance(); + cal.setTime(time); + cal.add(Calendar.MONTH, 1); + cal.set(Calendar.DAY_OF_MONTH, 0); + return getDate(dateToDateString(cal.getTime(), yyyy_MM_dd_EN)); + } + /** * ��������������������������������������������������� * @@ -1446,6 +1496,13 @@ return calendar.getTime(); } + //������������ + public static Date addYears(Date date, int years) { + Calendar calendar = Calendar.getInstance(); + calendar.setTime(date); + calendar.add(Calendar.YEAR, years); + return calendar.getTime(); + } /** * <p> -- Gitblit v1.8.0