java 获取近七天日期 //pom.xml中的maven依赖 dependency groupIdorg.apache.commons/groupId artifactIdcommons-lang3/artifactId /dependencypublic static ListString getSevenDate() { ListString dateList = new ArrayList(); SimpleDateForm
java 获取近七天日期
//pom.xml中的maven依赖 <dependency> <groupId>org.apache.commons</groupId> <artifactId>commons-lang3</artifactId> </dependency>public static List<String> getSevenDate() { List<String> 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; }