1. SimpleDateFormat myformat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
    2. Calendar c = Calendar.getInstance();
    3. //过去七天
    4. c.setTime(new Date());
    5. c.add(Calendar.DATE, - 7);
    6. Date d = c.getTime();
    7. String day = myformat.format(d);
    8. System.out.println("过去七天:"+day);
    9. //过去一月
    10. c.setTime(new Date());
    11. c.add(Calendar.MONTH, -1);
    12. Date m = c.getTime();
    13. String mon = myformat.format(m);
    14. System.out.println("过去一个月:"+mon);
    15. //过去三个月
    16. c.setTime(new Date());
    17. c.add(Calendar.MONTH,-3);
    18. System.out.println("过去三个月:"+myformat.format(c.getTime()));
    19. //过去一年
    20. c.setTime(new Date());
    21. c.add(Calendar.YEAR,-1);
    22. System.out.println("过去一年:"+myformat.format(c.getTime()));