Calendar calendar = Calendar.getInstance();//当天日期calendar.setTime(new Date());//前一天的日期
calendar.add(Calendar.DATE, -1); String yestedayDate = format1.format(calendar.getTime());
int dow=calendar.get(Calendar.DAY_OF_WEEK)-2; //这里应该是不减或减1,不知道为什么-2才对上if(dow==7) dow=0;//本周最小日期calendar.add(Calendar.DAY_OF_YEAR, -dow);String strDate=format1.format(calendar.getTime());//本周最大日期calendar.add(Calendar.DAY_OF_YEAR, 6);strDate=format1.format(calendar.getTime());
时间: 2024-10-12 21:46:34