日期:2014-05-20 浏览次数:20710 次
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); Calendar cal = Calendar.getInstance(); //最近三天 cal.add(Calendar.DAY_OF_YEAR, -3); //最近一周 cal.add(Calendar.WEEK_OF_YEAR, -1); //最近两周 cal.add(Calendar.WEEK_OF_YEAR, -2); //最近一个月 cal.add(Calendar.MONTH, -1); //最近两个月 cal.add(Calendar.MONTH, -2); Date d = cal.getTime(); System.out.println(sdf.format(d));
------解决方案--------------------