int month = 1;
int year =2021;
Calendar c1 = Calendar.getInstance();
//设置本月起始日的年月日时分秒格式
c1.set(year , month-1, 1, 0, 0, 0);
String beginMonthTime = sdf.format(c1.getTime());
//设置本月结束日的年月日时分秒格式
c1.set(year , month-1, c1.getActualMaximum(Calendar.DAY_OF_MONTH), 23, 59, 59);
String endMonthTime = sdf.format(c1.getTime());