Example usage for org.joda.time Days daysBetween

List of usage examples for org.joda.time Days daysBetween

Introduction

In this page you can find the example usage for org.joda.time Days daysBetween.

Prototype

public static Days daysBetween(ReadablePartial start, ReadablePartial end) 

Source Link

Document

Creates a Days representing the number of whole days between the two specified partial datetimes.

Usage

From source file:cherry.foundation.bizcal.BizYearManagerImpl.java

License:Apache License

@Override
public int getNumberOfDaysOfBizYear(LocalDate dt) {
    Range<LocalDate> range = bizYearByDate(dt).getRight();
    return Days.daysBetween(range.getMinimum(), range.getMaximum()).getDays() + 1;
}

From source file:cherry.foundation.bizcal.SimpleWorkdayStore.java

License:Apache License

@Override
public int getNumberOfWorkday(String name, LocalDate from, LocalDate to) {
    return Days.daysBetween(from, to).getDays() + 1;
}

From source file:cherry.spring.common.foundation.impl.WorkdayStoreImpl.java

License:Apache License

@Override
public int getNumberOfWorkday(String name, LocalDate from, LocalDate to) {
    SQLQuery query = queryDslJdbcOperations.newSqlQuery();
    query.from(h0);//from   w  ww. j av  a 2 s.  com
    query.where(h0.name.eq(name), h0.dt.between(constant(from), constant(to)),
            h0.deletedFlg.eq(NOT_DELETED.code()));
    long count = queryDslJdbcOperations.queryForObject(query, h0.dt.count());
    return Days.daysBetween(from, to).getDays() + 1 - (int) count;
}

From source file:cl.usach.managedbeans.EscritorioManagedBean.java

public String obtenerTiempo(Date inicio) {
    if (inicio == null)
        return "-";
    DateTime dtI = new DateTime(inicio);
    DateTime dtF = new DateTime(new Date());
    String tiempo = "";
    String aux;//from  w  w  w . ja  va  2s  .com
    if (Days.daysBetween(dtI, dtF).getDays() > 0)
        tiempo += Days.daysBetween(dtI, dtF).getDays() + " d, ";
    aux = Hours.hoursBetween(dtI, dtF).getHours() % 24 + ":";
    if (aux.length() == 2)
        aux = "0" + aux;
    tiempo += aux;
    aux = Minutes.minutesBetween(dtI, dtF).getMinutes() % 60 + "";
    if (aux.length() == 1)
        aux = "0" + aux;
    tiempo += aux + " hrs";
    return tiempo;
}

From source file:cl.usach.managedbeans.GraficoManagedBean.java

public Map<String, Number> inicializarMAP(Date fechai, Date fechaf) {
    Map<String, Number> valores = new HashMap<>();
    try {//ww w  .  j a v  a  2 s .c  o m
        fechai = formatter.parse(formatter.format(fechai));
        fechaf = formatter.parse(formatter.format(fechaf));

        DateTime datei = new DateTime(fechai);
        DateTime datef = new DateTime(fechaf);

        int dias = Days.daysBetween(datei, datef).getDays();
        for (int i = 0; i <= dias; i++) {
            DateTime d = datei.withFieldAdded(DurationFieldType.days(), i);
            valores.put(formatter.format(d.toDate()), 0);
        }
        return valores;

    } catch (ParseException ex) {
        Logger.getLogger(GraficoManagedBean.class.getName()).log(Level.SEVERE, null, ex);
        return null;
    }
}

From source file:co.malm.mglam_reads.backend.util.DateDiffUtil.java

License:Apache License

/**
 * Calculates time differences using two dates, and stores it into a
 * {@linkplain java.util.Map} object./*from   ww w .j  ava 2s.  c  om*/
 *
 * @param map calculations data
 * @param dt1 first date for diff
 * @param dt2 second date for diff
 * @see org.joda.time.DateTime
 * @see org.joda.time.Years
 * @see org.joda.time.Months
 * @see org.joda.time.Weeks
 * @see org.joda.time.Days
 * @see org.joda.time.Hours
 * @see org.joda.time.Minutes
 * @see org.joda.time.Seconds
 */
private void calculate(HashMap<String, Integer> map, DateTime dt1, DateTime dt2) {

    final int SECONDS_IN_MINUTE = 60;
    final int MINUTES_IN_HOUR = 60;
    final int HOURS_IN_DAY = 24;
    final int DAYS_IN_MONTH = 31;
    final int MONTHS_IN_YEAR = 12;
    final int WEEKS_IN_DAY = 7;

    int diffYears = Years.yearsBetween(dt1, dt2).getYears();
    if (diffYears > 0) {
        map.put("years", diffYears);
    }

    int diffMonths = Months.monthsBetween(dt1, dt2).getMonths();
    if (diffMonths >= 1 && diffMonths < MONTHS_IN_YEAR) {
        map.put("months", diffMonths);
    }

    int diffWeeks = Weeks.weeksBetween(dt1, dt2).getWeeks();
    if (diffWeeks >= 1 && diffWeeks < WEEKS_IN_DAY) {
        map.put("weeks", diffWeeks);
    }

    int diffDays = Days.daysBetween(dt1, dt2).getDays();
    if (diffDays >= 1 && diffDays < DAYS_IN_MONTH) {
        map.put("days", diffDays);
    }

    int diffHours = Hours.hoursBetween(dt1, dt2).getHours();
    if (diffHours >= 1 && diffHours < HOURS_IN_DAY) {
        map.put("hours", diffHours);
    }

    int diffMinutes = Minutes.minutesBetween(dt1, dt2).getMinutes();
    if (diffMinutes >= 1 && diffMinutes < MINUTES_IN_HOUR) {
        map.put("minutes", diffMinutes);
    }

    int diffSeconds = Seconds.secondsBetween(dt1, dt2).getSeconds();
    if (diffSeconds >= 1 && diffSeconds < SECONDS_IN_MINUTE) {
        map.put("seconds", diffSeconds);
    }
}

From source file:com.aptechfpt.controller.ProductReportController.java

/**
 * Processes requests for both HTTP <code>GET</code> and <code>POST</code>
 * methods./*from   w  ww  . ja  va2s  .c om*/
 *
 * @param request servlet request
 * @param response servlet response
 * @throws ServletException if a servlet-specific error occurs
 * @throws IOException if an I/O error occurs
 */
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
    try {
        InitialContext context = new InitialContext();
        productFacade = (ProductFacadeLocal) context.lookup(
                "java:global/Unify-ear/Unify-ejb-1.0-SNAPSHOT/ProductFacade!com.aptechfpt.bean.ProductFacadeLocal");
    } catch (Exception e) {
        e.printStackTrace();
    }
    response.setContentType("text/html;charset=UTF-8");
    try (PrintWriter out = response.getWriter()) {

        String date = request.getParameter("daterange");
        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("MM/dd/yyyy");
        String from = LocalDate.parse(date.split("-")[0].trim(), formatter).toString();
        String to = LocalDate.parse(date.split("-")[1].trim(), formatter).toString();
        DateTime fdate = DateTime.parse(from);
        DateTime tdate = DateTime.parse(to);
        List<Product> listproduct = productFacade.findAll();
        int tongsanpham = listproduct.size();
        int spdangban = 0, sphuyban = 0;
        for (Product p : listproduct) {
            if (p.getAvailable()) {
                spdangban++;
            } else
                sphuyban++;
        }

        List<Category> listcategory = categoryFacade.findAll();
        List<Product> listtoplike = productFacade.getTop10Like();
        List<HighSale> listtopsale = purchaseOrderDetailFacade.getTop10Buy(from, to);
        int days = Days.daysBetween(fdate, tdate).getDays();
        List<String> lname = new ArrayList();
        List<Integer> lquanity = new ArrayList();
        for (HighSale i : listtopsale) {
            lname.add(i.getProductName());
            lquanity.add(i.getQuantity());
        }
        List<HighSale> listtopcomment = commentFacade.getTop10Comment(from, to);

        HttpSession s = request.getSession();
        s.setAttribute("tongsanpham", tongsanpham);
        s.setAttribute("spdangban", spdangban);
        s.setAttribute("sphuyban", sphuyban);
        s.setAttribute("listcategory", listcategory);
        s.setAttribute("listtoplike", listtoplike);
        s.setAttribute("listtopsale", listtopsale);
        s.setAttribute("listtopcomment", listtopcomment);
        s.setAttribute("from", from);
        s.setAttribute("to", to);
        s.setAttribute("day", days);
        s.setAttribute("names", lname);
        s.setAttribute("quantity", lquanity);
        request.getRequestDispatcher("WEB-INF/admin/productreportview.jsp").forward(request, response);
    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:com.aptechfpt.controller.PurchaseReportController.java

/**
 * Processes requests for both HTTP <code>GET</code> and <code>POST</code>
 * methods.//from w w  w.  j a va  2 s .  co m
 *
 * @param request servlet request
 * @param response servlet response
 * @throws ServletException if a servlet-specific error occurs
 * @throws IOException if an I/O error occurs
 */
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
    try {
        InitialContext context = new InitialContext();
        purchaseOrderFacade = (PurchaseOrderFacadeLocal) context.lookup(
                "java:global/Unify-ear/Unify-ejb-1.0-SNAPSHOT/PurchaseOrderFacade!com.aptechfpt.bean.PurchaseOrderFacadeLocal");
    } catch (Exception e) {
        e.printStackTrace();
    }
    response.setContentType("text/html;charset=UTF-8");
    try (PrintWriter out = response.getWriter()) {
        request.setCharacterEncoding("UTF-8");
        String date = request.getParameter("daterange");
        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("MM/dd/yyyy");
        String from = LocalDate.parse(date.split("-")[0].trim(), formatter).toString();
        String to = LocalDate.parse(date.split("-")[1].trim(), formatter).toString();
        DateTime fdate = DateTime.parse(from);
        DateTime tdate = DateTime.parse(to);
        List<PurchaseOrder> list = purchaseOrderFacade.getReport(fdate, tdate);
        double doanhthu = 0, loinhuan = 0;
        int donhang = list.size();
        int hanghoa = 0, hoanthanh = 0, giaohang = 0;
        int access = 0, dress = 0, pant = 0, shirt = 0, cancel = 0;
        for (PurchaseOrder p : list) {
            if (p.getCancelInvoice()) {
                if (p.getStatus()) {
                    doanhthu += p.getSubTotal().doubleValue();
                    hoanthanh++;
                    for (PurchaseOrderDetail pod : p.getPurchaseOrderDetailCollection()) {
                        hanghoa += pod.getQuantity();
                        loinhuan += (pod.getUnitPrice().doubleValue() - pod.getCost().doubleValue())
                                * pod.getQuantity();
                        if (pod.getProductId().getSubCategoryId().getCategoryId().getName()
                                .equalsIgnoreCase("Accessory")) {
                            access += pod.getQuantity();
                        }
                        if (pod.getProductId().getSubCategoryId().getCategoryId().getName()
                                .equalsIgnoreCase("Dress")) {
                            dress += pod.getQuantity();
                        }
                        if (pod.getProductId().getSubCategoryId().getCategoryId().getName()
                                .equalsIgnoreCase("Pants")) {
                            pant += pod.getQuantity();
                        }
                        if (pod.getProductId().getSubCategoryId().getCategoryId().getName()
                                .equalsIgnoreCase("Shirt")) {
                            shirt += pod.getQuantity();
                        }
                    }
                } else {
                    giaohang++;
                }
            } else {
                cancel++;
            }

        }

        MaHoa mh = new MaHoa();
        for (PurchaseOrder p : list) {
            p.setName(mh.decrypt(p.getName()));
            p.setAddress(mh.decrypt(p.getAddress()));
            p.setPhone(mh.decrypt(p.getPhone()));

        }
        int days = Days.daysBetween(fdate, tdate).getDays();
        //            request.setAttribute("doanhthu", doanhthu);
        //            request.setAttribute("loinhuan", loinhuan);
        //            request.setAttribute("hanghoa", hanghoa);
        //            request.setAttribute("donhang", donhang);
        //            request.setAttribute("hoanthanh", hoanthanh);
        //            request.setAttribute("giaohang", giaohang);
        //
        //            request.setAttribute("acc", access);
        //            request.setAttribute("pant", pant);
        //            request.setAttribute("dress", dress);
        //            request.setAttribute("shirt", shirt);
        //            request.setAttribute("cancel", cancel);
        //            request.setAttribute("list", list);

        HttpSession session = request.getSession();
        session.setAttribute("doanhthu", doanhthu);
        session.setAttribute("loinhuan", loinhuan);
        session.setAttribute("hanghoa", hanghoa);
        session.setAttribute("donhang", donhang);
        session.setAttribute("hoanthanh", hoanthanh);
        session.setAttribute("giaohang", giaohang);

        session.setAttribute("acc", access);
        session.setAttribute("pant", pant);
        session.setAttribute("dress", dress);
        session.setAttribute("shirt", shirt);
        session.setAttribute("cancel", cancel);
        session.setAttribute("list", list);
        session.setAttribute("day", days);
        session.setAttribute("from", from);
        session.setAttribute("to", to);
        request.getRequestDispatcher("WEB-INF/admin/reportprint.jsp").forward(request, response);
    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:com.aurel.track.exchange.msProject.exporter.MsProjectExporterBL.java

License:Open Source License

/**
 * Add or update the task//  w w  w.j av  a  2  s.  c  o  m
 * 
 * @param taskElement
 * @param workItemBean
 * @param msProjectTaskBean
 * @param taskID
 * @param outlineStructure
 * @param budgetBean
 * @param actualEstimatedBudgetBean
 * @param hoursPerWorkday
 * @param workItemCosts
 * @param hasChildren
 * @param defaultTaskType
 * @param durationFormat
 * @param isNew
 */
private static void addUpdateTask(ProjectFile project, Task taskElement, TWorkItemBean workItemBean,
        TMSProjectTaskBean msProjectTaskBean, int taskID, OutlineStructure outlineStructure,
        TComputedValuesBean computedValueBean, TActualEstimatedBudgetBean actualEstimatedBudgetBean,
        Double hoursPerWorkday, List<TCostBean> workItemCosts, boolean hasChildren, Integer defaultTaskType,
        Integer durationFormat, boolean isNew,
        Map<Integer, Map<String, List<String[]>>> calendarUIDBasedBaseCalendarExceptionWorkingTimes,
        Map<Integer, Map<Integer, List<String[]>>> calendarUIDBasedBaseCalendarWeekDayWorkingTimes,
        LocalLookupContainer localLookupContainer) {

    outlineStructure.incCurrentLevel();
    SystemWBSRT systemWbs = new SystemWBSRT();
    if (msProjectTaskBean.getUniqueID() != null) {
        if (taskElement == null) {
            taskElement = project.addTask();
        }
        // taskElement.setUniqueID( msProjectTaskBean.getUniqueID());
        taskElement.setConstraintType(ConstraintType.getInstance(msProjectTaskBean.getConstraintType()));
        taskElement.setConstraintDate(msProjectTaskBean.getConstraintDate());
        taskElement.setDeadline(msProjectTaskBean.getDeadline());
    }
    // taskElement.setID(Integer.valueOf(taskID));
    taskElement.setName(workItemBean.getSynopsis());
    taskElement.setUniqueID(workItemBean.getObjectID());
    if (isNew && defaultTaskType != null) {
        taskElement.setType(TaskType.getInstance(defaultTaskType));
    }
    taskElement.setCreateDate(workItemBean.getCreated());

    String wbs = systemWbs.getShowValue(SystemFields.WBS, null, workItemBean.getWBSOnLevel(),
            workItemBean.getObjectID(), localLookupContainer, null);
    taskElement.setOutlineNumber(wbs);
    // taskElement.setID(workItemBean.getIDNumber());
    StringTokenizer stringTokenizer = new StringTokenizer(wbs, ".");
    int numberOfLevels = stringTokenizer.countTokens() - 1;
    if (numberOfLevels == 0) {
        taskElement.setOutlineLevel(1);
    } else {
        taskElement.setOutlineLevel(numberOfLevels + 1);
    }
    /*
     * if(msProjectTaskBean.getOutlineNumber() != null) {
     * taskElement.setOutlineNumber(msProjectTaskBean.getOutlineNumber());
     * }else { //
     * taskElement.setOutlineLevel(outlineStructure.getAbsoluteLevel()); }
     */
    if (workItemBean.getStartDate() != null && workItemBean.getEndDate() != null) {
        taskElement.setStart(workItemBean.getTopDownStartDate());

        taskElement.setActualStart(workItemBean.getStartDate());
        taskElement.setActualFinish(workItemBean.getEndDate());

        /*
         * taskElement.setEarlyStart(workItemBean.getStartDate());
         * taskElement.setLateStart(workItemBean.getStartDate());
         * taskElement.setEarlyFinish(workItemBean.getEndDate());
         * taskElement.setLateFinish(workItemBean.getEndDate());
         */

        taskElement.setFinish(workItemBean.getTopDownEndDate());

        SimpleDateFormat formatter = new SimpleDateFormat("dd/MM/yyyy");

        if (formatter.format(workItemBean.getStartDate())
                .compareTo(formatter.format(workItemBean.getEndDate())) == 0) {
            taskElement.setDuration(Duration.getInstance(1, TimeUnit.DAYS));
            taskElement.setManualDuration(Duration.getInstance(1, TimeUnit.DAYS));
        } else {
            int days = Days.daysBetween(new DateTime(workItemBean.getStartDate()),
                    new DateTime(workItemBean.getEndDate())).getDays();
            taskElement.setDuration(Duration.getInstance(days, TimeUnit.DAYS));
        }
    } else if (workItemBean.getStartDate() != null && workItemBean.getEndDate() == null) {
        taskElement.setStart(workItemBean.getStartDate());
        taskElement.setMilestone(true);
    }
    taskElement.setPercentageComplete(0);
    taskElement.setPercentageWorkComplete(0);
    taskElement.setNotes(workItemBean.getDescription());
    // from budgetBean we need only the time unit because the
    // exported budget is the sum of actual work and remaining work
    if (computedValueBean != null) {
        // prepare this transformed values for hasChanged because the
        // MSProject work seems to be in hours TODO?
        /*
         * Double transformedHours =
         * AccountingBL.transformToTimeUnits(budgetBean.getEstimatedHours(),
         * hoursPerWorkday, budgetBean.getTimenit(),
         * AccountingBL.TIMEUNITS.HOURS); if (transformedHours!=null) {
         * plannedWorkHours = transformedHours.doubleValue(); }
         */
        if (isNew && durationFormat == null) {
            // for new projects (without previous import the project level
            // durationFormat is null)
            if (AccountingBL.TIMEUNITS.HOURS.equals(computedValueBean.getMeasurementUnit())) {
                durationFormat = LAG_FORMAT.h;
            } else {
                durationFormat = LAG_FORMAT.d;
            }
        }
    }
    // TODO should we set the duration?
    // Element durationElement =
    // MsProjectExchangeDOMHelper.getChildByName(taskElement,
    // TASK_ELEMENTS.Duration);
    if (isNew && durationFormat != null) {
        // TODO setDuartionFormat method missing
        // MsProjectExchangeDOMHelper.setChildTextByName(taskElement,
        // TASK_ELEMENTS.DurationFormat, durationFormat.toString(), false);
        // taskElement.setDuration(Duration.getInstance(arg0,
        // durationFormat));
    }
    int summary;
    if (hasChildren) {
        summary = TASK_SUMMARY_TYPE.SUMMARY;
    } else {
        summary = TASK_SUMMARY_TYPE.NOT_SUMMARY;
    }
    taskElement.setSummary(summary > 0 ? true : false);
    double actualHours = getSumOfActualWorks(workItemCosts);
    try {
        // taskElement.setActualDuration(Duration.getInstance(actualHours,
        // TimeUnit.HOURS));

    } catch (Exception ex) {
        LOGGER.error("Date parse error: " + ex.getMessage());
    }
    double remainingWorkHours = 0.0;
    if (actualEstimatedBudgetBean != null) {
        Double transformedHours = AccountingBL.transformToTimeUnits(
                actualEstimatedBudgetBean.getEstimatedHours(), hoursPerWorkday,
                actualEstimatedBudgetBean.getTimeUnit(), AccountingBL.TIMEUNITS.HOURS);
        if (transformedHours != null) {
            remainingWorkHours = transformedHours.doubleValue();
        }
    } else {
        if (isNew && Math.abs(actualHours) < EPSILON && workItemBean.getStartDate() != null
                && workItemBean.getEndDate() != null) {
            // "simulate" a remaining value for issue in order to appear the
            // startDate and endDate in MSProject
            // as it was set in Genji although to work was set in Genji.
            Date dateFrom = workItemBean.getStartDate();
            Calendar calendar = Calendar.getInstance();
            calendar.setTime(dateFrom);
            CalendarUtil.clearTime(calendar);
            List<String[]> workingPeriods = null;
            while (calendar.getTime().before(workItemBean.getEndDate())
                    || calendar.getTime().getTime() == workItemBean.getEndDate().getTime()) {
                try {
                    workingPeriods = getWorkingTimeForDay(null, null,
                            calendarUIDBasedBaseCalendarExceptionWorkingTimes.values().iterator().next(),
                            calendarUIDBasedBaseCalendarWeekDayWorkingTimes.values().iterator().next(),
                            calendar.getTime());
                } catch (Exception ex) {
                    LOGGER.debug("Element missing: " + ex.getMessage());
                }
                if (workingPeriods != null) {
                    for (Iterator itrWorkPeriod = workingPeriods.iterator(); itrWorkPeriod.hasNext();) {
                        // try each workingTime interval to see where the
                        // work can be added
                        String[] workingTime = (String[]) itrWorkPeriod.next();
                        String fromTime = workingTime[0];
                        String toTime = workingTime[1];
                        Map<String, Integer> timeUnitsMapFromTime = MsProjectExchangeBL
                                .getTimeUnitsMapFromCalendarTime(fromTime);
                        Map<String, Integer> timeUnitsMapToTime = MsProjectExchangeBL
                                .getTimeUnitsMapFromCalendarTime(toTime);
                        double hourDiff = MsProjectExchangeBL.getHoursDiff(timeUnitsMapFromTime,
                                timeUnitsMapToTime);
                        remainingWorkHours += hourDiff;
                    }
                }
                calendar.add(Calendar.DATE, 1);
            }
        }
    }
    taskElement.setRemainingWork(Duration.getInstance(remainingWorkHours, TimeUnit.HOURS));
    taskElement.setRemainingDuration(Duration.getInstance(remainingWorkHours, TimeUnit.HOURS));
    // the planned work is forced to be the sum of actual work and actual
    // hours
    // (instead of the plannedWorkHours) because otherwise MSProject result
    // is not consistent
    taskElement.setWork(Duration.getInstance(remainingWorkHours + actualHours, TimeUnit.HOURS));
    int days = Days
            .daysBetween(new DateTime(workItemBean.getStartDate()), new DateTime(workItemBean.getEndDate()))
            .getDays();
    taskElement.setDuration(Duration.getInstance(days, TimeUnit.DAYS));
    taskElement.setActualWork(null);
    // not really needed to update because in track+ UI they are not
    // modifiable: for new tasks
    // the msProjectTaskBean is new for existing tasks they can be taken
    // from the last imported file
    if (isNew && Math.abs(actualHours) < EPSILON) {
        if (workItemBean.getStartDate() != null) {
            msProjectTaskBean.setConstraintType(CONSTRAINT_TYPE.START_NO_EARLIER_THAN);
            msProjectTaskBean.setConstraintDate(workItemBean.getStartDate());
        } else {
            if (workItemBean.getEndDate() != null) {
                msProjectTaskBean.setConstraintType(CONSTRAINT_TYPE.FINISH_NO_LATER_THAN);
                msProjectTaskBean.setConstraintDate(workItemBean.getEndDate());
            }
        }
    }
}

From source file:com.aurel.track.linkType.MsProjectLinkTypeBL.java

License:Open Source License

/**
 * Returns number of free days from given interval, start date included always, endDate only if includeLastDay == true!
 * @param startDateParam/*from   w w  w.  j a  va2  s  . c  o m*/
 * @param endDateParam
 * @param includeLastDay
 * @return
 */
public static Integer getNumberOfDaysBetweenDates(Date startDateParam, Date endDateParam,
        boolean includeLastDay) {
    DateTime dateTime1 = new DateTime(startDateParam);
    DateTime dateTime2 = new DateTime(endDateParam);
    if (includeLastDay) {
        dateTime2 = dateTime2.plusDays(1);
    }
    int numberOfDays = Days.daysBetween(dateTime1, dateTime2).getDays();
    return numberOfDays;
}