chenjiahe
2022-08-04 1daac0aa9998b3a483966bbdf859c45e64e682a2
src/main/java/com/hx/util/DateUtil.java
@@ -51,6 +51,17 @@
        return df.format(date);
    }
    /**时间戳转时间
     * @param timestamp 时间戳
     * @param format 时间格式
     * @return 返回的时间格式字符串
     */
    public static Date timestampToDate(long timestamp, String format) {
        SimpleDateFormat sdf= new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        String sd = sdf.format(new Date(timestamp));      // 时间戳转换成时间
        return DateUtil.parseString(sd,"yyyy-MM-dd HH:mm:ss");
    }
    /**
     * 转换成yyyyMMdd格式的日期字符串
     *
@@ -191,6 +202,20 @@
        return Format_14.format(date);
    }
    /**
     * 当前时间之前的时间与当前时间相差多少秒
     * @param startDate 当前时间之前的时间
     * @return
     */
    public static int calLastedTime(Date startDate) {
        long nowDate = new Date().getTime();
        long startDateTime = startDate.getTime();
        int diffSeconds = (int) ((nowDate - startDateTime) / 1000);
        return diffSeconds;
    }
    /**
     * 转换成yyyyMMddHHmmssSSS格式的日期字符串
     *
@@ -277,6 +302,18 @@
        }
    }
    /**时间上秒叠加
     * @Author: ChenJiaHe
     * @param dateTime 时间
     * @param second 秒
     * @return
     */
    public static Date addSecond(Date dateTime,int second){
        Calendar c = Calendar.getInstance();
        c.setTime(dateTime);
        c.add(Calendar.SECOND, second);
        return c.getTime();
    }
    /**时间上分钟叠加
     * @Author: ChenJiaHe
@@ -445,7 +482,7 @@
       }
       boolean status = false;
       if(formatDate(startTime,"yyyyMMdd").equals(formatDate(endTime,"yyyyMMdd"))){
           status = false;
           status = true;
       }
       return status;
    }