2008년 2월 29일 금요일

JAVA : USE CALENDAR


boolean isAvailableDate(EventMainBean eventMain) throws Exception{
boolean result = false;

String pattern = "yyyyMMdd";

Calendar calendar = Calendar.getInstance();

SimpleDateFormat formatter = new SimpleDateFormat(pattern, new Locale("ko","KOREA"));

Date stDate = formatter.parse(eventMain.getDistributionStDate());
Date edDate = formatter.parse(eventMain.getDistributionEdDate());

Calendar stDateInCalendar = (Calendar)calendar.clone();
stDateInCalendar.setTime(stDate);

Calendar edDateInCalendar = (Calendar)calendar.clone();
edDateInCalendar.setTime(edDate);
edDateInCalendar.add(Calendar.DATE, 1);

if ( calendar.after(stDateInCalendar) && calendar.before(edDateInCalendar) )
result = true ;

System.out.println(calendar.after(stDateInCalendar));
System.out.println(calendar.before(edDateInCalendar));
System.out.println(result);
return result;
}

댓글 없음: