본문 바로가기
Web Program/Java Lecture

날짜 관련

by 현이빈이 2008. 8. 13.
반응형
Calendar today   = Calendar.getInstance();
  Calendar firstday  = Calendar.getInstance();
  Calendar lastday  = Calendar.getInstance();
 
  int p_year, p_month, p_day;
  p_year = today.get(Calendar.YEAR);
  p_month = today.get(Calendar.MONTH);
  p_day = today.get(Calendar.DAY_OF_MONTH);
   
  //out.println(p_month + "<BR>");
 
  firstday.set(p_year, p_month, 1);
  lastday.set(p_year, p_month+1, 1);
 
  int start_day = firstday.get(Calendar.DAY_OF_WEEK);
  int to_day = today.get(Calendar.DATE);
 
 
  lastday.add(Calendar.DATE,-1); //해당월의 마지막 날짜
  int end_day = (int)lastday.get(Calendar.DATE); //해당월의 마지막 날짜 
반응형