//格式化类,选择自己需要的格式化类 年月日
DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
SimpleDateFormat timeFormat = new SimpleDateFormat("HH:mm:ss");
SimpleDateFormat dateTimeFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
//日历类
Calendar calendar = Calendar.getInstance();
calendar.set(Calendar.DAY_OF_MONTH, 1);//当月的第一天
System.out.println(dateFormat.format(calendar.getTime()));
calendar.add(Calendar.MONTH, 1);//月份加1
calendar.set(Calendar.DAY_OF_MONTH, 0);//当月的最后一天,0就代表上个月的最后一天