package com.aa;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.Locale;
public class ThisWeek {
public static void main(String[] args) {
String dateString = "20190719";
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd");
Date date = new Date();
try{
date = sdf.parse(dateString);
System.out.println("date="+date);
}catch(ParseException e){
}
Calendar cal = Calendar.getInstance(Locale.KOREA);
cal.setTime(date);
System.out.println("입력한 날짜 : "+sdf.format(cal.getTime()));
cal.add(Calendar.DATE, 2 - cal.get(Calendar.DAY_OF_WEEK));
System.out.println("첫번째 요일(월요일)날짜:"+sdf.format(cal.getTime()));
cal.setTime(date);
cal.add(Calendar.DATE, 8 - cal.get(Calendar.DAY_OF_WEEK));
System.out.println("마지막 요일(일요일)날짜:"+sdf.format(cal.getTime()));
}
}