Javaで週の最初(最後)の日、月のの最初(最後)の日を求める方法

Javaコード:
Calendar calendar=Calendar.getInstance();
calendar.setTime(new Date());
SimpleDateFormat sdf=new SimpleDateFormat(“yyyy-MM-dd”);
SimpleDateFormat sdfall=new SimpleDateFormat(“yyyy-MM-dd HH:mm:ss”);

//日付の開始、終了時間
startDate=sdf.parse(sdf.format(calendar.getTime()));
endDate=sdfall.parse(sdf.format(calendar.getTime())+” 23:59:59″);

//週の最初の日、最後の日
calendar.setFirstDayOfWeek(Calendar.MONDAY);
calendar.set(Calendar.DAY_OF_WEEK,calendar.getFirstDayOfWeek());
startDate=sdf.parse(sdf.format(calendar.getTime()));
calendar.set(Calendar.DAY_OF_WEEK,calendar.getFirstDayOfWeek()+6);
endDate=sdfall.parse(sdf.format(calendar.getTime())+” 23:59:59″);

//当月の最初の日、最後の日
calendar.set(calendar.get(Calendar.YEAR),calendar.get(Calendar.MONTH), 1);
startDate=sdf.parse(sdf.format(calendar.getTime()));
calendar.roll(Calendar.DATE, -1);
endDate=sdfall.parse(sdf.format(calendar.getTime())+” 23:59:59″);