//날짜 클래스 생성
Date curDate = new Date();
  
//날짜형식 변환
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd");
sdf.format(curDate);
  
//현재날짜 출력
System.out.println("today : " + sdf.format(curDate));

 

//어제날짜 계산
Date yesterDay = new Date();
yesterDay.setTime(curDate.getTime() - ((long)(1000 * 60 * 60 * 24) * 2));
  
//어제날짜 출력
System.out.println("yesterDay : " + sdf.format(yesterDay));

 

+ Recent posts