Calendar cal = Calendar.getInstance();
cal.set(Calendar.DAY_OF_WEEK, Calendar.MONDAY);
cal.set(Calendar.HOUR_OF_DAY,0);
cal.set(Calendar.MINUTE,0);
cal.set(Calendar.SECOND,0);
date1 = cal.getTime();
SimpleDateFormat sdf =newSimpleDateFormat("yyyy-MM-dd");
Calendar c = Calendar.getInstance();
List<String> dates =newArrayList<>();
dates.add(sdf.format(date1));for(int i =1; i <7; i++){
c.setTime(date1);
c.add(Calendar.DAY_OF_MONTH, i);
Date date2 = c.getTime();
dates.add(sdf.format(date2));}
月
获取本月第一天
public Date getmindate(){
Calendar calendar = Calendar.getInstance();
calendar.setTime(newDate());
calendar.set(Calendar.DAY_OF_MONTH,calendar.getActualMinimum(Calendar.DAY_OF_MONTH));return calendar.getTime();}
获取本月最后一天
public Date getmaxdate(){
Calendar calendar2 = Calendar.getInstance();
calendar2.setTime(newDate());
calendar2.set(Calendar.DAY_OF_MONTH, calendar2.getActualMaximum(Calendar.DAY_OF_MONTH));return calendar2.getTime();}
Calendar cale =null;
cale = Calendar.getInstance();
int year = cale.get(Calendar.YEAR);
int month = cale.get(Calendar.MONTH)+1;
int day = cale.get(Calendar.DATE);
int hour = cale.get(Calendar.HOUR_OF_DAY);
int minute = cale.get(Calendar.MINUTE);
int second = cale.get(Calendar.SECOND);