SimpleDateFormat df =new SimpleDateFormat("yyyyMMdd");
//获取上个月第一天时间 ,当前月减去1获取上月月份,获取第一天日期
Calendar calendar = Calendar.getInstance();
calendar.add(Calendar.MONTH, -1);
calendar.set(Calendar.DAY_OF_MONTH, 1);
String berforeFirstDay = df.format(calendar.getTime());
//获取当前月第一天日期,减去一天,获取上个月最后一天时间
Calendar calendar1 = Calendar.getInstance();
calendar1.set(Calendar.DAY_OF_MONTH, 1);
calendar1.add(Calendar.DATE, -1);
String berforeLastDay = df.format(calendar1.getTime());
//获取当前月第一天时间
Calendar calendar2 = Calendar.getInstance();
calendar2.set(Calendar.DAY_OF_MONTH, 1);
String firstDay = df.format(calendar2.getTime());
//先获取下个月第一天日期,减去一天,获取当前月最后一天时间
Calendar calendar3 = Calendar.getInstance();
calendar3.add(Calendar.MONTH, 1);
calendar3.set(Calendar.DAY_OF_MONTH, 1);
calendar3.add(Calendar.DATE, -1);
String lastDay = df.format(calendar3.getTime());