java 获取近七天日期

java 获取近七天日期

//pom.xml中的maven依赖
		 
            org.apache.commons
            commons-lang3
        
 public static List getSevenDate() {
        List dateList = new ArrayList<>();
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
        for (int i = 0; i < 7; i++) {
            Date date = DateUtils.addDays(new Date(), -i);
            String formatDate = sdf.format(date);
            dateList.add(formatDate);
        }
        return dateList;
    }

你可能感兴趣的:(springboot,java工具,java,日期,后端,http,spring,boot)