private boolean isExceedThreashold(Date date) {

    Days daysBetweenCreationTimeAndNow = Days.daysBetween(new DateTime(date), DateTime.now());

    return daysBetweenCreationTimeAndNow.getDays()
        >= Integer.parseInt(VerigreenNeededLogic.VerigreenMap.get("daysThreashold"));
  }
 private Duration estimateIntervalStep(String interval) {
   Duration step;
   switch (interval) {
     case "minute":
       step = Minutes.ONE.toStandardDuration();
       break;
     case "hour":
       step = Hours.ONE.toStandardDuration();
       break;
     case "day":
       step = Days.ONE.toStandardDuration();
       break;
     case "week":
       step = Weeks.ONE.toStandardDuration();
       break;
     case "month":
       step = Days.days(31).toStandardDuration();
       break;
     case "quarter":
       step = Days.days(31 * 3).toStandardDuration();
       break;
     case "year":
       step = Days.days(365).toStandardDuration();
       break;
     default:
       throw new IllegalArgumentException("Invalid duration specified: " + interval);
   }
   return step;
 }
  /**
   * Handle an account state warning produced by ldaptive account state machinery.
   *
   * <p>Override this method to provide custom warning message handling.
   *
   * @param warning the account state warning messages.
   * @param response Ldaptive authentication response.
   * @param configuration Password policy configuration.
   * @param messages Container for messages produced by account state warning handling.
   */
  protected void handleWarning(
      final AccountState.Warning warning,
      final AuthenticationResponse response,
      final LdapPasswordPolicyConfiguration configuration,
      final List<Message> messages) {

    logger.debug("Handling warning {}", warning);
    if (warning == null) {
      logger.debug("Account state warning not defined");
      return;
    }

    final Calendar expDate = warning.getExpiration();
    final Days ttl = Days.daysBetween(Instant.now(), new Instant(expDate));
    logger.debug(
        "Password expires in {} days. Expiration warning threshold is {} days.",
        ttl.getDays(),
        configuration.getPasswordWarningNumberOfDays());
    if (configuration.isAlwaysDisplayPasswordExpirationWarning()
        || ttl.getDays() < configuration.getPasswordWarningNumberOfDays()) {
      messages.add(
          new PasswordExpiringWarningMessage(
              "Password expires in {0} days. Please change your password at <href=\"{1}\">{1}</a>",
              ttl.getDays(), configuration.getPasswordPolicyUrl()));
    }
    if (warning.getLoginsRemaining() > 0) {
      messages.add(
          new Message(
              "password.expiration.loginsRemaining",
              "You have {0} logins remaining before you MUST change your password.",
              warning.getLoginsRemaining()));
    }
  }
Exemple #4
0
  public static void main(String[] args) {
    String dayStrBegin = "2016-03-14";
    String dayStrEnd = "2016-03-20";

    String datePattern = "yyyy-MM-dd";
    DateTimeFormatter dateFormatter = DateTimeFormat.forPattern(datePattern);

    LocalDate localDateStart = dateFormatter.parseLocalDate(dayStrBegin);
    LocalDate localDateEnd = dateFormatter.parseLocalDate(dayStrEnd);

    // 比较大小,不返回相差的天数
    // localDateStart.compareTo(localDateEnd);

    // 减去一个Period,不能应用于localDateEnd
    // localDateStart.minus(ReadablePeriod);

    // minus的入参是ReadablePeriod
    // Duration ninetyDays = new Duration(NINETY_DAYS_MILLI);

    /*
     * Period ninetyDays = new Period(NINETY_DAYS_MILLI); LocalDate limitStart = localDateEnd.minus(ninetyDays); if
     * (localDateStart.compareTo(limitStart) != -1) { System.out.println("Hi, there"); }
     */

    Days durationDays = Days.daysBetween(localDateStart, localDateEnd);
    if (durationDays.getDays() <= 90) {
      System.out.println("Hi, there");
    }
  }
    @Override
    public void run() {
      while (true) {
        final MeasurementDataNumeric data;
        try {
          data = numericQueue.take();
          if (data == KILL_SIGNAL) {
            return;
          }
        } catch (InterruptedException e) {
          // We still keep getting interrupted.. we really need to die
          return;
        }
        DateTime collectionTimeSlice =
            dateTimeService.getTimeSlice(
                new DateTime(data.getTimestamp()), configuration.getRawTimeSliceDuration());
        Days days = Days.daysBetween(collectionTimeSlice, dateTimeService.now());

        if (days.isGreaterThan(rawDataAgeLimit)) {
          log.info(
              data
                  + " is older than the raw data age limit of "
                  + rawDataAgeLimit.getDays()
                  + " days. It will not be stored.");
        } else {
          StorageResultSetFuture rawFuture = dao.insertRawData(data);
          StorageResultSetFuture indexFuture =
              dao.updateIndex(
                  IndexBucket.RAW, collectionTimeSlice.getMillis(), data.getScheduleId());
          ListenableFuture<List<ResultSet>> insertsFuture =
              Futures.successfulAsList(rawFuture, indexFuture);
          Futures.addCallback(
              insertsFuture,
              new FutureCallback<List<ResultSet>>() {
                @Override
                public void onSuccess(List<ResultSet> result) {}

                @Override
                public void onFailure(Throwable t) {
                  boolean offerSuccess = numericQueue.offer(data);
                  if (!offerSuccess) {
                    if (log.isDebugEnabled()) {
                      log.debug(
                          "An error occurred while inserting raw data",
                          ThrowableUtil.getRootCause(t));
                    } else {
                      log.warn(
                          "An error occurred while inserting raw data: "
                              + ThrowableUtil.getRootMessage(t)
                              + ", data was: "
                              + data);
                    }
                  }
                }
              },
              tasks);
        }
      }
    }
Exemple #6
0
  public int gap(TimeId start) {
    Days days = Days.daysBetween(start.getDateTime().toLocalDate(), dateTime.toLocalDate());

    return days.getDays() * 288 + timeId - start.getTimeId();

    //        if(a >= 0) {
    //            return (a * 288) + timeId - start.getTimeId();
    //        } else {
    //            return (a * 288) + timeId - start.getTimeId();
    //        }
  }
 private boolean isWebserviceInvocationAllowed(Calltype callType, Timestamp lastInvocation) {
   boolean oldEnough;
   if (lastInvocation == null) {
     oldEnough = true;
   } else if (lastInvocation.getTime() >> 32 == Integer.MAX_VALUE) {
     // checks if invocation_time is close enough to 'infinity'.
     oldEnough = false;
   } else {
     DateTime lastInvocationDateTime = new DateTime(lastInvocation.getTime());
     Days daysBetween = Days.daysBetween(lastInvocationDateTime, new DateTime());
     oldEnough = daysBetween.getDays() > callType.getDaysToCache();
   }
   return oldEnough;
 }
  /**
   * Defines the magnitudes that can be added to the timestamp
   *
   * @param token token of form "[number][magnitude]" (ex. "1d")
   * @return integer indicating the magnitude of the date for the calendar system
   */
  public static ReadablePeriod getTimePeriod(String token) {
    String valString = token.substring(0, token.length() - 1);
    int value = Integer.parseInt(valString);
    char mag = token.charAt(token.length() - 1);

    ReadablePeriod period;

    switch (mag) {
      case 's':
        period = Seconds.seconds(value);
        break;
      case 'm':
        period = Minutes.minutes(value);
        break;
      case 'h':
        period = Hours.hours(value);
        break;
      case 'd':
        period = Days.days(value);
        break;
      case 'M':
        period = Months.months(value);
        break;
      case 'y':
        period = Years.years(value);
        break;
      default:
        logger.warn("Invalid date magnitude: {}. Defaulting to seconds.", mag);
        period = Seconds.seconds(value);
        break;
    }

    return period;
  }
  public static int getRecurrencesBetween(
      RecurrenceInterval interval, int multiplier, Date start, Date end) {
    DateTime then = new DateTime(start);
    DateTime now = new DateTime(end);

    int count = 1;
    switch (interval) {
      case ONCE:
        break;
      case DAY:
        count += Days.daysBetween(then, now).getDays() / multiplier;
        break;
      case MONTH:
        count += Months.monthsBetween(then, now).getMonths() / multiplier;
        break;
      case QUARTER:
        int quarters = Months.monthsBetween(then, now).getMonths() / 3;
        count += quarters / multiplier;
        break;
      case YEAR:
        count += Years.yearsBetween(then, now).getYears() / multiplier;
        break;
    }

    return count;
  }
 @Override
 protected boolean isToFire() {
   int days =
       Days.daysBetween(calculateStartDate().toDateMidnight(), new LocalDate().toDateMidnight())
           .getDays();
   return days >= INTERVAL;
 }
  private void when_all_jobs_within_X_days_are_executed(int days) {
    Date date = DateTime.now().plus(Days.days(days)).toDate();
    Job job = managementService.createJobQuery().duedateLowerThan(date).singleResult();

    assertThat(job, notNullValue());
    managementService.executeJob(job.getId());
  }
Exemple #12
0
 /**
  * 计算两个日期之间的时间间隔(不计算毫秒数)
  *
  * @param date1,date2
  * @param timeType
  * @return int
  */
 public static int periodBtDate(Date date1, Date date2, TimeType timeType) {
   if (date1 == null || date2 == null) {
     throw new IllegalArgumentException("date param can not be null");
   }
   DateTime start = fromDate(date1);
   DateTime end = fromDate(date2);
   int period = 0;
   switch (timeType.getCode()) {
     case "Y":
       period = Years.yearsBetween(start, end).getYears();
       break;
     case "M":
       period = Months.monthsBetween(start, end).getMonths();
       break;
     case "W":
       period = Weeks.weeksBetween(start, end).getWeeks();
       break;
     case "D":
       period = Days.daysBetween(start, end).getDays();
       break;
     case "H":
       period = Hours.hoursBetween(start, end).getHours();
       break;
     case "MIN":
       period = Minutes.minutesBetween(start, end).getMinutes();
       break;
     case "S":
       period = Seconds.secondsBetween(start, end).getSeconds();
       break;
     default:
       break;
   }
   return Math.abs(period);
 }
 private int getDaysLeftForReview(PhdThesisProcess process) {
   return Days.daysBetween(
           process
               .getWhenJuryValidated()
               .plusDays(PhdReporterReviewAlert.getReporterReviewDeadlineDays()),
           new LocalDate())
       .getDays();
 }
  @Test
  public void testWhenQuotesAreOnlyAvailableFromTheMiddleOfTheReportInterval() {
    DateMidnight startDate = new DateMidnight(2012, 12, 31);
    DateMidnight middleDate = new DateMidnight(2013, 2, 18);
    DateMidnight endDate = new DateMidnight(2013, 4, 1);

    // create model

    Client client = new Client();

    new AccountBuilder() //
        .deposit_(startDate, 100 * Values.Amount.factor()) //
        .interest(startDate.plusDays(10), 10 * Values.Amount.factor()) //
        .addTo(client);

    Security security =
        new SecurityBuilder() //
            .generatePrices(50 * Values.Amount.factor(), middleDate, endDate) //
            .addTo(client);

    // calculate performance indices

    List<Exception> warnings = new ArrayList<Exception>();

    ReportingPeriod reportInterval =
        new ReportingPeriod.FromXtoY(startDate.toDate(), endDate.toDate());
    ClientIndex clientIndex = PerformanceIndex.forClient(client, reportInterval, warnings);
    PerformanceIndex securityIndex = PerformanceIndex.forSecurity(clientIndex, security, warnings);

    // asserts

    assertTrue(warnings.isEmpty());

    Date[] clientDates = clientIndex.getDates();
    Date[] securityDates = securityIndex.getDates();

    assertThat(securityDates[0], is(middleDate.toDate()));
    assertThat(securityDates[securityDates.length - 1], is(endDate.toDate()));
    assertThat(
        new DateMidnight(clientDates[clientDates.length - 1]),
        is(new DateMidnight(securityDates[securityDates.length - 1])));

    double[] clientAccumulated = clientIndex.getAccumulatedPercentage();
    double[] securityAccumulated = securityIndex.getAccumulatedPercentage();

    int index = Days.daysBetween(startDate, middleDate).getDays();
    assertThat(new DateMidnight(clientDates[index]), is(middleDate));
    assertThat(securityAccumulated[0], IsCloseTo.closeTo(clientAccumulated[index], 0.000001d));

    long middlePrice = security.getSecurityPrice(middleDate.toDate()).getValue();
    long lastPrice = security.getSecurityPrice(endDate.toDate()).getValue();

    // 10% is interest of the deposit
    double performance = (double) (lastPrice - middlePrice) / (double) middlePrice + 0.1d;
    assertThat(
        securityAccumulated[securityAccumulated.length - 1],
        IsCloseTo.closeTo(performance, 0.000001d));
  }
Exemple #15
0
  // Disconnection credit price
  protected BigDecimal getDisconnectionCredit(
      LocalDate startDate,
      LocalDate endDate,
      BigDecimal amount,
      String durationType,
      Integer chargeDuration) {

    LocalDate durationDate = startDate.plusMonths(chargeDuration).minusDays(1);
    int divisibleDays = Days.daysBetween(startDate, durationDate).getDays() + 1;
    int maxDaysOfMonth = startDate.dayOfMonth().withMaximumValue().getDayOfMonth();
    int maximumDaysInYear = new LocalDate().dayOfYear().withMaximumValue().getDayOfYear();
    BigDecimal pricePerDay = BigDecimal.ZERO;

    int totalDays = 0;
    if (startDate.isEqual(endDate)) {
      totalDays = 0;
    } else {
      // int numberOfMonths =
      // Months.monthsBetween(startDate,endDate).getMonths();
      // LocalDate tempBillEndDate = endDate.minusMonths(numberOfMonths);
      totalDays = Days.daysBetween(startDate, endDate).getDays() + 1;
    }

    if (durationType.equalsIgnoreCase("month(s)")) {

      if (chargeDuration == 12) {
        pricePerDay = amount.divide(new BigDecimal(maximumDaysInYear), RoundingMode.HALF_UP);

      } else if (chargeDuration != 1) {
        pricePerDay = amount.divide(new BigDecimal(divisibleDays), RoundingMode.HALF_UP);

      } else {
        pricePerDay = amount.divide(new BigDecimal(maxDaysOfMonth), RoundingMode.HALF_UP);
      }
    } else if (durationType.equalsIgnoreCase("week(s)")) {

      Integer billingDays = 7 * chargeDuration;

      pricePerDay = amount.divide(new BigDecimal(billingDays), RoundingMode.HALF_UP);
    }

    return pricePerDay.multiply(new BigDecimal(totalDays));
  }
  /**
   * Calculate how long a movie is showing based on starting date and ending date
   *
   * @param sD Start Date
   * @param eD End Date
   * @return
   */
  public static int calculateRunDate(Date sD, Date eD) {

    int minusDays = 0;
    DateTime dt1 = new DateTime(sD);
    DateTime dt2 = new DateTime(eD);

    minusDays = Days.daysBetween(dt1, dt2).getDays();

    return minusDays;
  }
Exemple #17
0
 public void setRawDataAgeLimit(int rawDataAgeLimit) {
   if (rawDataAgeLimit > RAW_DATA_AGE_LIMIT_MAX) {
     throw new IllegalArgumentException(
         "The requested limit, "
             + rawDataAgeLimit
             + ", exceeds the max age "
             + "limit of "
             + RAW_DATA_AGE_LIMIT_MAX);
   }
   this.rawDataAgeLimit = Days.days(rawDataAgeLimit);
 }
  public List<Sessao> criaSessoes(
      LocalDate inicio, LocalDate fim, LocalTime horario, Periodicidade periodicidade) {

    if (inicio.isBefore(fim)) {
      throw new IllegalArgumentException("A data de início deve ser menor que a data fim");
    }

    Days numeroDias = Days.daysBetween(inicio, fim);

    return null;
  }
 public int getDaysInInterval(Interval interval) {
   LocalDate beginDate =
       getBeginDate().isBefore(interval.getStart().toLocalDate())
           ? interval.getStart().toLocalDate()
           : getBeginDate();
   LocalDate endDate =
       getEndDate() == null || getEndDate().isAfter(interval.getEnd().toLocalDate())
           ? interval.getEnd().toLocalDate()
           : getEndDate();
   return Days.daysBetween(beginDate, endDate).getDays();
 }
 public static int getDaysBetween(final String date1, final String date2, String format) {
   try {
     final DateTimeFormatter fmt =
         DateTimeFormat.forPattern(format)
             .withChronology(LenientChronology.getInstance(GregorianChronology.getInstance()));
     return Days.daysBetween(fmt.parseDateTime(date1), fmt.parseDateTime(date2)).getDays();
   } catch (Exception ex) {
     ex.printStackTrace();
     return 0;
   }
 }
 public double getStartAsFractionOfPeriod(DateTime beginOfPeriod, DateTime endOfPeriod) {
   if (isCovered(beginOfPeriod, endOfPeriod)) {
     if (start.isBefore(beginOfPeriod)) { // { ? beginOfPeriod : start;
       return 0;
     } else {
       return Days.daysBetween(beginOfPeriod, start).getDays()
           / coveredPeriodLength(beginOfPeriod, endOfPeriod);
     }
   } else {
     return -1;
   }
 }
 public double getEndAsFractionOfPeriod(DateTime beginOfPeriod, DateTime endOfPeriod) {
   if (isCovered(beginOfPeriod, endOfPeriod)) {
     if (end.isAfter(endOfPeriod)) {
       return 1;
     } else {
       return Days.daysBetween(beginOfPeriod, end).getDays()
           / coveredPeriodLength(beginOfPeriod, endOfPeriod);
     }
   } else {
     return -1;
   }
 }
 /**
  * Extends the CSV row
  *
  * @param row existing row
  * @return the extended row
  */
 public String[] extendRow(String[] row) {
   List<String> rowExt = new ArrayList<String>();
   for (int i = 0; i < dateColumnIndexes.size(); i++) {
     SourceColumn c = dates.get(i);
     int idx = dateColumnIndexes.get(i);
     int adjustedDataIndex =
         ((identityColumn >= 0) && (idx >= identityColumn)) ? (idx - 1) : (idx);
     String dateValue = row[idx];
     if (dateValue != null && dateValue.trim().length() > 0) {
       try {
         DateTimeFormatter formatter = dateColumnFormats.get(i);
         DateTime dt = formatter.parseDateTime(dateValue);
         Days ds = Days.daysBetween(base, dt);
         rowExt.add(Integer.toString(ds.getDays() + 1));
         if (c.isDatetime()) {
           int ts = dt.getSecondOfDay();
           rowExt.add(Integer.toString(ts));
           String scs = Integer.toString(ts);
           rowExt.add((scs.length() > 1) ? (scs) : ("0" + scs));
         }
       } catch (IllegalArgumentException e) {
         l.debug("Can't parse date " + dateValue);
         rowExt.add("");
         if (c.isDatetime()) {
           rowExt.add("");
           rowExt.add("00");
         }
       }
     } else {
       rowExt.add("");
       if (c.isDatetime()) {
         rowExt.add("");
         rowExt.add("00");
       }
     }
   }
   if (rowExt.size() > 0) return mergeArrays(row, rowExt.toArray(new String[] {}));
   else return row;
 }
  /**
   * Finds closest time key in raster to specified time value
   *
   * @param timValue Time value
   * @return Closest time value
   */
  private LocalDate findNearestTimeKey() {

    // timFloor = floor value
    // timCeiling = ceiling value

    LocalDate timFloor;
    LocalDate timCeiling;

    if (!tim1.isAfter(mapDate.firstKey())) {
      return mapDate.firstKey();
    } else if (!tim1.isBefore(mapDate.lastKey())) {
      return mapDate.lastKey();
    } else {
      timFloor = mapDate.floorKey(tim1);
      timCeiling = mapDate.ceilingKey(tim1);
      if (Days.daysBetween(timFloor, tim1).getDays()
          < Days.daysBetween(tim1, timCeiling).getDays()) {
        return timFloor;
      } else {
        return timCeiling;
      }
    }
  }
Exemple #25
0
  public List<Days> getWorkingDaysAsJodaTimeDays() {

    List<Days> jodaWorkingDays = new ArrayList<Days>();

    List<WeekDay> workingDaysAsWeekDays = getWorkingDays();
    for (WeekDay weekDay : workingDaysAsWeekDays) {

      Days jodaWeekDay =
          Days.days(WeekDay.getJodaDayOfWeekThatMatchesMifosWeekDay(weekDay.getValue()));

      jodaWorkingDays.add(jodaWeekDay);
    }

    return jodaWorkingDays;
  }
Exemple #26
0
 /**
  * 求两个直接的日期差,月份.
  *
  * <p>*MSECONDS|*SECONDS|*MINUTES|*HOURS|*DAYS|*MONTHS|*YEARS
  *
  * @param tDate 日期格式"20150404"
  * @param txDate 日期格式"20150404"
  * @param type type 选择 DAYS||MONTHS||YEARS
  * @return
  */
 public static int diff(String tDate, String txDate, String type) {
   if (txDate != null && tDate != null) {
     DateTime txDT = DateTime.parse(txDate, ISODateTimeFormat.basicDate());
     DateTime tDT = DateTime.parse(tDate, ISODateTimeFormat.basicDate());
     if (type.toUpperCase().endsWith("DAYS")) {
       return Days.daysBetween(txDT, tDT).getDays();
     } else if (type.toUpperCase().endsWith("MONTHS")) {
       return Months.monthsBetween(txDT, tDT).getMonths();
     } else if (type.toUpperCase().endsWith("YEARS")) {
       return Years.yearsBetween(txDT, tDT).getYears();
     } else if (type.toUpperCase().endsWith("YEARS")) {
       return Years.yearsBetween(txDT, tDT).getYears();
     }
   }
   return 0;
 }
 private DateTime nextRepeatDaily(DateTime midnightTomorrow) {
   if (schedule.getRepeatRate() == 1) {
     return midnightTomorrow;
   }
   int distanceBetweenStartAndTomorrow =
       Days.daysBetween(new DateTime(schedule.getBeginDate()).toDateMidnight(), midnightTomorrow)
           .getDays();
   if (distanceBetweenStartAndTomorrow == 0
       || distanceBetweenStartAndTomorrow == schedule.getRepeatRate()) {
     return midnightTomorrow;
   } else if (distanceBetweenStartAndTomorrow > schedule.getRepeatRate()) {
     int remainder = distanceBetweenStartAndTomorrow % schedule.getRepeatRate();
     return midnightTomorrow.plusDays(schedule.getRepeatRate() - remainder);
   } else {
     return midnightTomorrow.plusDays(schedule.getRepeatRate() - distanceBetweenStartAndTomorrow);
   }
 }
Exemple #28
0
  // Pro rate Weekly Bill
  public BillingOrderCommand getProrataWeeklyFirstBill(
      BillingOrderData billingOrderData, DiscountMasterData discountMasterData) {

    LocalDate startDate = null;
    LocalDate endDate = null;
    BigDecimal price = null;
    LocalDate invoiceTillDate = null;
    LocalDate nextbillDate = null;

    startDate = new LocalDate(billingOrderData.getBillStartDate());
    endDate = startDate.dayOfWeek().withMaximumValue();
    LocalDate weekStartDate = startDate.dayOfWeek().withMinimumValue();
    Plan plan = this.planRepository.findOne(billingOrderData.getPlanId());

    int totalDays = 0;

    totalDays = Days.daysBetween(startDate, endDate).getDays() + 1;
    BigDecimal weeklyPricePerDay = getWeeklyPricePerDay(billingOrderData);

    Integer billingDays = 7 * billingOrderData.getChargeDuration();

    if (totalDays < billingDays) {
      price = weeklyPricePerDay.multiply(new BigDecimal(totalDays));
      if (plan.getBillRule() == 300 && !startDate.equals(weekStartDate)) {
        price = BigDecimal.ZERO;
      }
    } else if (totalDays == billingDays) {
      price = billingOrderData.getPrice();
    }

    invoiceTillDate = endDate;
    nextbillDate = endDate.plusDays(1);

    List<InvoiceTaxCommand> listOfTaxes =
        this.calculateDiscountAndTax(
            billingOrderData, discountMasterData, startDate, endDate, price);
    return this.createBillingOrderCommand(
        billingOrderData,
        startDate,
        endDate,
        invoiceTillDate,
        nextbillDate,
        price,
        listOfTaxes,
        discountMasterData);
  }
  private float getNbJoursForAbsence(DemandeAbsence absence) throws Exception {

    // nombre de jours d'écart entre datedeb et dateFin
    float nbJours =
        Days.daysBetween(new DateTime(absence.getDateDebut()), new DateTime(absence.getDateFin()))
            .getDays();
    nbJours += 1;

    if (absence.getDebutPM()) {
      nbJours -= 0.5;
    }
    if (absence.getFinAM()) {
      nbJours -= 0.5;
    }

    // recup des jours feries
    List<Date> joursFeries = null;
    try {
      joursFeries = calendarService.getJourFeries();
    } catch (Exception e) {
      throw new Exception(e.getMessage());
    }

    // les samedis et dimanche ne sont pas pris en compte
    // supprimer les jours feries
    GregorianCalendar calendar = new GregorianCalendar();
    calendar.setTime(absence.getDateDebut());
    // gestion des dates différentes dans le cloud
    while (!DateUtils.isSameDay(calendar.getTime(), absence.getDateFin())) {
      // System.out.println("!!!! " + calendar.getTime() + ">" +
      // calendar.get(Calendar.DAY_OF_WEEK));
      if (calendar.get(Calendar.DAY_OF_WEEK) == 1 || calendar.get(Calendar.DAY_OF_WEEK) == 7) {
        nbJours -= 1;
      }
      if (joursFeries.contains(calendar.getTime())) {
        nbJours -= 1;
      }
      calendar.add(Calendar.DATE, 1);
    }

    return nbJours;
  }
 private void checkDates(JobOfferBean bean) {
   LocalDate beginDate = bean.getBeginDate();
   LocalDate endDate = bean.getEndDate();
   if (beginDate.isAfter(endDate)) {
     throw new DomainException(
         "message.jobOffer.beginDate.isAfter.endDate",
         ResourceBundle.getBundle(JobBankSystem.JOB_BANK_RESOURCES, Language.getLocale()));
   }
   int days = Days.daysBetween(bean.getBeginDate(), bean.getEndDate()).getDays();
   if (days < getMinNumberActiveDaysOffer()) {
     throw new DomainException(
         "message.error.jobOffer.min.active.days.offer",
         DomainException.getResourceFor(JobBankSystem.JOB_BANK_RESOURCES),
         getMinNumberActiveDaysOffer().toString());
   }
   if (days > getMaxNumberActiveDaysOffer()) {
     throw new DomainException(
         "message.error.jobOffer.max.active.days.offer",
         DomainException.getResourceFor(JobBankSystem.JOB_BANK_RESOURCES),
         getMaxNumberActiveDaysOffer().toString());
   }
 }