Calendar calendar = Calendar.getInstance();//此时打印它获取的是系统当前时间
calendar.add(Calendar.DATE, -1); //得到前一天
String yestedayDate= new SimpleDateFormat("yyyy-MM-dd").format(calendar.getTime());
paramsMap.put("time",yestedayDate);
- Date d = new Date();
- int m = d.getMonth();
- int y = d.getYear();
- Date firstDay = new Date(y,m+1,1) ;
- int min = 24*60*60*1000;
- Date from = new Date(y,m,1);
- Date to = new Date(firstDay.getTime()-min);
- System.out.println("第一天:"+from+"\n最后一天:"+to);