//设置日期格式及获取当前日期
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
Date date = new Date();
//获得日历 并把当前时间放入日历中
Calendar calendar = Calendar.getInstance();
calendar.setTime(date);
//返回日期的前一天 从日历中获取出来 按格式输出
calendar.add(Calendar.DAY_OF_MONTH, -1);
date = calendar.getTime();
System.out.println(sdf.format(date));
-----------------------------------当前日期的前一天---------------------------------------
//设置日期格式及获取当前日期
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
Date date = new Date();
//获得日历 并把当前时间放入日历中
Calendar calendar = Calendar.getInstance();
calendar.setTime(date);
//计算当前月份-1
calendar.add(Calendar.MONTH, -1);
//设时间为当前月份的第一天
calendar.set(Calendar.DAY_OF_MONTH, 1);
date = calendar.getTime();
System.out.println(sdf.format(date));
String fy = sdf.format(date);
------------------------------上一月份的第一天---------------------------------------