日期计算

SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM月dd日");
Calendar calendar = Calendar.getInstance(); //得到日历
calendar.setTime(calendar.getTime());//把当前时间赋给日历
calendar.add(Calendar.DAY_OF_MONTH, -1); //设置为前一天
Date dBefore = calendar.getTime(); //得到前一天的时间
System.out.println(sdf.format(dBefore));

原文地址:https://www.cnblogs.com/shenjun/p/3092964.html