zhangherong
2 天以前 8904f9e6005e7e1f3cc06f415fdcde0033c32332
lxzn-boot-base-core/src/main/java/org/jeecg/common/util/DateUtils.java
@@ -688,6 +688,7 @@
        calendar.setTime(getDate());
        return calendar.get(Calendar.YEAR);
    }
    public static String getDayStr(Date date) {
        Calendar calendar = getCalendar();
        calendar.setTime(date);// 把当前时间赋给日历
@@ -695,15 +696,16 @@
        String dayStr = day < 10 ? "0" + day : day + "";
        return dayStr;
    }
    /**
     * 将字符串转成时间
     * @param str
     * @return
     */
    public static Date parseDatetime(String str){
    public static Date parseDatetime(String str) {
        try {
            return datetimeFormat.get().parse(str);
        }catch (Exception e){
        } catch (Exception e) {
        }
        return null;
    }
@@ -711,7 +713,7 @@
    /**
     * 获取指定时间之后的几年 qsw
     */
    public static Date getYearAfter(Date data,int number) {
    public static Date getYearAfter(Date data, int number) {
        Calendar c = Calendar.getInstance();
        c.setTime(data);
        c.add(Calendar.YEAR, number);
@@ -724,7 +726,7 @@
    /**
     * 获取指定时间之后的几天 qsw
     */
    public static Date getDayAfter(Date data,int number) {
    public static Date getDayAfter(Date data, int number) {
        Calendar c = Calendar.getInstance();
        c.setTime(data);
        c.add(Calendar.DAY_OF_MONTH, number);
@@ -737,7 +739,7 @@
    /**
     * 获取指定时间之后的几分钟 qsw
     */
    public static Date getMinAfter(Date data,int number) {
    public static Date getMinAfter(Date data, int number) {
        Calendar c = Calendar.getInstance();
        c.setTime(data);
        c.add(Calendar.MINUTE, number);
@@ -748,7 +750,7 @@
    /**
     * 获取指定时间之后的几小时 qsw
     */
    public static Date getHourAfter(Date data,int number) {
    public static Date getHourAfter(Date data, int number) {
        Calendar c = Calendar.getInstance();
        c.setTime(data);
        c.add(Calendar.HOUR_OF_DAY, number);
@@ -780,4 +782,17 @@
    public static Date localDateToDate(LocalDate localDate) {
        return Date.from(localDate.atStartOfDay(ZoneId.systemDefault()).toInstant());
    }
    /**
     * 日期加年
     * @param date
     * @param year
     * @return
     */
    public static Date addYear(Date date, int year) {
        Calendar calendar = Calendar.getInstance();
        calendar.setTime(date);
        calendar.add(Calendar.YEAR, year);
        return calendar.getTime();
    }
}