//获取最近一周的日期
String[] getBeforeWeekOfDate(){
Calendar calendar=Calendar.getInstance();
//当前日期是2017-06-5
String[]oneWeekDate=new String[7];
SimpleDateFormat sf=new SimpleDateFormat("yyyy-MM-dd");
for(int i=0;i<7;i++){
calendar.add(Calendar.DAY_OF_MONTH, -1);
oneWeekDate[i]=sf.format(calendar.getTime()).toString();
}
return oneWeekDate;
}
//结果是
// 2017-06-04
// 2017-06-03
// 2017-06-02
// 2017-06-01
// 2017-05-31
// 2017-05-30
// 2017-05-29
获取前一周的日期
最新推荐文章于 2023-04-25 11:10:48 发布
353

被折叠的 条评论
为什么被折叠?



