jiangping
2025-02-28 69283b5a4559509187516355602e32e4bdac9d5d
server/services/src/main/java/com/doumee/core/utils/DateUtil.java
@@ -68,6 +68,32 @@
        return dt1;
    }
    public static Date StringToDateFormat(String DATE,String format) {
        if(StringUtils.isBlank(DATE)){
            return null;
        }
        DateFormat df = new SimpleDateFormat(format);
        Date dt1 = null;
        try {
            dt1 = df.parse(DATE);
        } catch (Exception exception) {
            exception.printStackTrace();
        }
        return dt1;
    }
    public static String getXDaysAfter(Date date, Integer days){
        Timestamp currentTimestamp = new Timestamp(date.getTime());
        Calendar calendar = Calendar.getInstance();
        calendar.setTime(currentTimestamp);
        calendar.add(Calendar.DAY_OF_YEAR, days); // 在当前时间基础上添加指定的天数
        SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
        return formatter.format(calendar.getTime());
    }
    /**
     * @author Pablo Descrption:ȡ�õ�ǰ����getgetg get Date format
     *         Example:2008-05-15
@@ -2154,19 +2180,19 @@
    /**
     * 得出两个日期之间的间隔天数
     *
     * @param strFromDate
     * @param smallDate
     *            格式为yyyy-MM-dd
     * @param strToDate
     * @param bigDate
     *            格式为yyyy-MM-dd
     * @return int
     */
    public static long getBetweenDays(String strFromDate, String strToDate) {
    public static long getBetweenDays(String smallDate, String bigDate) {
        long m_intervalday = 0;// 初始化时间间隔的值为0
        // 使用的时间格式为yyyy-MM-dd
        SimpleDateFormat m_simpledateformat = new SimpleDateFormat("yyyy-MM-dd");
        try {
            Date fromDate = m_simpledateformat.parse(strFromDate);
            Date toDate = m_simpledateformat.parse(strToDate);
            Date fromDate = m_simpledateformat.parse(smallDate);
            Date toDate = m_simpledateformat.parse(bigDate);
            m_intervalday = toDate.getTime() - fromDate.getTime();// 计算所得为微秒数
            m_intervalday = m_intervalday / 1000 / 60 / 60 / 24;// 计算所得的天数
@@ -2762,8 +2788,7 @@
    public static void main(String[] args) {
        try {
            System.out.println((int)(3.222));
            System.out.println(DateUtil.getCurrDate());
        } catch (Exception ex) {
            ex.printStackTrace();
        }