Java

현재 주의 월요일의 날짜를 가져오기

griffy 2009. 7. 27. 16:33

 //현재 주의 월요일의 날짜를 가져옴.
 Calendar cal = Calendar.getInstance(Locale.KOREA);
 while(cal.get(Calendar.DAY_OF_WEEK) != Calendar.MONDAY) {
  cal.add(Calendar.DATE, -1);
 }
 st_date = CommonUtil.getDate(cal.getTime(), "yyyyMMdd");

===============================================================
 public static String getDate(Date pDate, String pFormat) {
       
        if(pDate == null)
            return "";
           
  StringBuffer ret = new StringBuffer();
  new SimpleDateFormat(pFormat).format(pDate, ret, new FieldPosition(0));
  return ret.toString();
 }