SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy/MM");
Date date = new Date();
Calendar calendar = Calendar.getInstance();
calendar.setTime(date); // 设置为当前时间
calendar.set(Calendar.MONTH, calendar.get(Calendar.MONTH) - 1); // 设置为上一个月
date = calendar.getTime();
String dateStr = dateFormat.format(date);

 

posted on 2018-09-30 10:08  沛昕的博客  阅读(733)  评论(0编辑  收藏  举报