예제 #1
0
 @Override
 public GwtRpcResponseList<WeekInterface> execute(
     WeekSelectorRequest command, SessionContext context) {
   GwtRpcResponseList<WeekInterface> ret = new GwtRpcResponseList<WeekInterface>();
   Session session = SessionDAO.getInstance().get(command.getSessionId());
   Calendar c = Calendar.getInstance(Locale.US);
   c.setTime(session.getEventBeginDate());
   while (c.get(Calendar.DAY_OF_WEEK) != Calendar.MONDAY) {
     c.add(Calendar.DAY_OF_YEAR, -1);
   }
   int sessionYear = session.getSessionStartYear();
   Formats.Format<Date> df = Formats.getDateFormat(Formats.Pattern.DATE_EVENT_SHORT);
   while (!c.getTime().after(session.getEventEndDate())) {
     int dayOfYear = c.get(Calendar.DAY_OF_YEAR);
     if (c.get(Calendar.YEAR) < sessionYear) {
       Calendar x = Calendar.getInstance(Locale.US);
       x.set(c.get(Calendar.YEAR), 11, 31, 0, 0, 0);
       dayOfYear -= x.get(Calendar.DAY_OF_YEAR);
     } else if (c.get(Calendar.YEAR) > sessionYear) {
       Calendar x = Calendar.getInstance(Locale.US);
       x.set(sessionYear, 11, 31, 0, 0, 0);
       dayOfYear += x.get(Calendar.DAY_OF_YEAR);
     }
     WeekInterface week = new WeekInterface();
     week.setDayOfYear(dayOfYear);
     for (int i = 0; i < 7; i++) {
       week.addDayName(
           new DateInterface(
               df.format(c.getTime()), c.get(Calendar.MONTH) + 1, c.get(Calendar.DAY_OF_MONTH)));
       c.add(Calendar.DAY_OF_YEAR, 1);
     }
     ret.add(week);
   }
   return ret;
 }