|
Calendar ca = Calendar.getInstance();
java.util.Date nowdate = new java.util.Date();//得到当前时间
ca.setTime(nowdate);
ca.set(Calendar.DAY_OF_YEAR, ca.get(Calendar.DAY_OF_YEAR)-2);//你想要前几天的,就减去几天
Date beforDate = new Date(ca.getTimeInMillis());//这个就是前n天的时间
//java.text.SimpleDateFormat dateformat1= new java.text.SimpleDateFormat("yyyy-MM-dd");
String startD = new java.text.SimpleDateFormat("yyyy-MM-dd").format(beforDate);
String endDate = new java.text.SimpleDateFormat("yyyy-MM-dd").format(new Date());
这样就可以想要什么样就有什么样的??? |
|