jiaosong
2023-10-18 c96b05ab329834d16ec2aad7a35e66dfa02511c1
server/services/src/main/java/com/doumee/core/utils/DateUtil.java
@@ -293,6 +293,15 @@
            throw e;
        }
    }
    public static String getShortDateStr(Date date)   {
        String nowDate = "";
        try {
            nowDate = sdfShort.format(date);
            return nowDate;
        } catch (Exception e) {
           return  null;
        }
    }
    /**
     * Descrption:取得当前日期,格式为:YYYY-MM-DD
@@ -2298,6 +2307,16 @@
            return new Timestamp(System.currentTimeMillis());
        }
    }
    public static Date getDateFromString2(String strDate) {
        if (StringUtils.isEmpty(strDate)) {
            return new Date(System.currentTimeMillis());
        }
        try {
            return sdfLongTimePlus.parse(strDate);
        } catch (Exception ex) {
           return  null;
        }
    }
    // -----------------------------------------------------------------------
    public static Date parseFromFormats(String aValue) {
@@ -2984,6 +3003,24 @@
        return cal.getTime();
    }
    /**
     * 2个日期之间相差分钟数
     * @param begin
     * @param end
     * @return
     */
    public static Integer betweenMin(Date begin, Date end) {
        if(begin ==null || end == null){
            return  0;
        }
        long createTime =begin.getTime();//获取创建时间的时间戳
        long currentTime =Objects.isNull(end)?System.currentTimeMillis():end.getTime();//获取当前时间的时间戳
        long diff=(currentTime-createTime)/1000/60;//获取两个时间相差的分钟
        return (int)diff;
    }
    /**
     * 计算耗时
     * @param start
@@ -3003,4 +3040,4 @@
        return consuming.toString();
    }
}
}