// 获取当前年份、月份、日期
Calendar cale = null;
cale = Calendar.getInstance();
// 获取当月第一天和最后一天
SimpleDateFormat formatTemp = new SimpleDateFormat("yyyy-MM-dd");
String firstday, lastday;
// 获取当前月的第一天
cale = Calendar.getInstance();
cale.add(Calendar.MONTH, 0);
cale.set(Calendar.DAY_OF_MONTH, 1);
firstday = formatTemp.format(cale.getTime());
// 获取当前月的最后一天
cale = Calendar.getInstance();
cale.add(Calendar.MONTH, 1);
cale.set(Calendar.DAY_OF_MONTH, 0);
lastday = formatTemp.format(cale.getTime());
System.out.println("firstday:"+firstday+" lastday:"+lastday);
//控制台输出
//firstday:2019-07-01 lastday:2019-07-31