小老虎的开发记述【九】Java从当前时间获取到上个月&获取到上周

Calendar c = Calendar.getInstance(); c.add(Calendar.MONTH, -1); System.out.println("上个月是:"+new SimpleDateFormat("yyyy-MM-dd").format(c.getTime()));

Calendar c = Calendar.getInstance(); c.add(Calendar.WEEK_OF_MONTH, -1); System.out.println("上周是:"+new SimpleDateFormat("yyyy-MM-dd").format(c.getTime()));

    推荐阅读