import cn.hutool.core.date.DateField;
import cn.hutool.core.date.DateUtil;
/**
* 获取最近7天的日期
* @return List
*/
private List<LastWeekDateVo> generate7DateList(){
List<LastWeekDateVo> list = new ArrayList<>();
Date currentDate = new Date();
for (int i=6; i>=1; i--){
LastWeekDateVo dateVo = new LastWeekDateVo();
Date newDate = DateUtil.offset(currentDate, DateField.DAY_OF_MONTH, -i);
String formatDate = DateUtil.formatDate(newDate);
dateVo.setDateStr(formatDate);
list.add(dateVo);
}
String format1 = DateUtil.formatDate(currentDate);
LastWeekDateVo currentDateVo = new LastWeekDateVo();
currentDateVo.setDateStr(format1);
list.add(currentDateVo);
return list;
}
// LastWeekDateVo类:
@Data标签:DateUtil,list,List,列表,日期,formatDate,new,LastWeekDateVo From: https://www.cnblogs.com/heyi-77/p/17361630.html
public class LastWeekDateVo {
@ApiModelProperty(value = "最新7天的日期")
private String dateStr;
}