Ejemplo n.º 1
0
  public void updateCalendar(Date date, Date fromHour, Date toHour) {
    GregorianCalendar cal = new GregorianCalendar();
    cal.setTime(date);
    int day = cal.get(Calendar.DAY_OF_WEEK);
    DayEnum dayEnum = null;
    if (Calendar.MONDAY == day) {
      dayEnum = DayEnum.MONDAY;
    }
    if (Calendar.TUESDAY == day) {
      dayEnum = DayEnum.TUESDAY;
    }
    if (Calendar.WEDNESDAY == day) {
      dayEnum = DayEnum.WEDNESDAY;
    }
    if (Calendar.THURSDAY == day) {
      dayEnum = DayEnum.THURSDAY;
    }
    if (Calendar.FRIDAY == day) {
      dayEnum = DayEnum.FRIDAY;
    }
    if (Calendar.SUNDAY == day) {
      dayEnum = DayEnum.SUNDAY;
    }
    if (Calendar.SATURDAY == day) {
      dayEnum = DayEnum.SATURDAY;
    }

    for (DayRange dayRange : calendar) {

      if (dayRange.getDayEnum().equals(dayEnum)) {
        dayRange.setRange(fromHour, toHour);
        dayRange.save();
      }
    }
  }
Ejemplo n.º 2
0
 private void completeCalendar() {
   List<DayEnum> dayEnums = DayEnum.getDayEnums();
   Date fromHour = new Date();
   fromHour.setHours(0);
   fromHour.setMinutes(0);
   fromHour.setSeconds(0);
   Date toHour = new Date();
   toHour.setHours(23);
   toHour.setMinutes(0);
   toHour.setSeconds(0);
   for (DayEnum dayEnum : dayEnums) {
     DayRange aux = new DayRange();
     aux.setDayEnum(dayEnum);
     aux.setRange(fromHour, toHour);
     calendar.add(aux);
   }
 }