111
k94314517
2023-09-13 f06d894f2f15798d24a13d15360ac9fa5e8461d1
server/src/main/java/doumeemes/core/utils/DateUtil.java
@@ -983,6 +983,17 @@
        return dt1;
    }
    public static Date StringToDateShort(String DATE) {
        DateFormat df = new SimpleDateFormat("yyyy-MM-dd");
        Date dt1 = null;
        try {
            dt1 = df.parse(DATE);
        } catch (Exception exception) {
            exception.printStackTrace();
        }
        return dt1;
    }
    /**
     * 获取输入格式的日期字符串,字符串遵循Oracle格式
     *
@@ -3025,4 +3036,19 @@
        return from;
    }
    public static String afterDate(String date,int num){
        Date today = DateUtil.StringToDateShort(date);   //当前时间
        Calendar calendar = Calendar.getInstance(); //得到日历
        calendar.setTime(today);//把当前时间赋给日历
        calendar.add(Calendar.DAY_OF_MONTH, num);  //设置为前一天
        Date yesterday = calendar.getTime();   //得到前一天的时间
        calendar.setTime(today);
        calendar.add(Calendar.DAY_OF_MONTH, 1);  //设置为后一天
        Date tomorrow = calendar.getTime();
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); //设置时间格式
        return sdf.format(calendar.getTime());
    }
}