Example usage for org.joda.time LocalDate equals

List of usage examples for org.joda.time LocalDate equals

Introduction

In this page you can find the example usage for org.joda.time LocalDate equals.

Prototype

public boolean equals(Object partial) 

Source Link

Document

Compares this ReadablePartial with another returning true if the chronology, field types and values are equal.

Usage

From source file:ca.ualberta.physics.cssdp.dao.type.PersistentLocalDate.java

License:Apache License

@Override
public boolean equals(Object x, Object y) throws HibernateException {

    if (x == y) {
        return true;
    }/*from   ww w.  j  av  a  2s . co m*/

    if (x == null || y == null) {
        return false;
    }

    LocalDate ldt1 = (LocalDate) x;
    LocalDate ldt2 = (LocalDate) y;

    return ldt1.equals(ldt2);
}

From source file:com.axelor.apps.base.service.scheduler.SchedulerService.java

License:Open Source License

/**
 * Mthode qui dtermine si une instance de planificateur peut etre lanc
 *
 * @param schedulerI/*from  w  w w  . j ava  2  s.  co  m*/
 *       Instance de planificateur
 *
 * @return boolean
 *       True si il est temps de lancer, sinon False
 *
 * @throws AxelorException
 */
public boolean isSchedulerInstanceIsReady(SchedulerInstance schedulerI) throws AxelorException {

    LocalDate firstExecution = schedulerI.getFirstExecutionDate();
    LocalDate lastTheoreticalExecution = schedulerI.getLastTheoreticalExecutionDate();

    //Si date de dmarrage egal ou suprieur  date du jour
    if (lastTheoreticalExecution == null) {
        LOG.debug("Date de dernire excution absente");
        if (firstExecution == null) {
            LOG.debug(String.format("Date de premiere executon absente"));
        } else if (firstExecution.equals(today) || firstExecution.isBefore(today)) {
            LOG.debug("Date de dmarrage suprieur ou gal a date du jour");
            return true;
        } else {
            LOG.debug(String.format("La facturation ne peux pas encore tre excut : %s < %s", today,
                    firstExecution));
        }
    } else {
        //Sinon calcul le cycle
        return this.processScheduler(schedulerI);
    }

    return false;
}

From source file:com.axelor.apps.base.service.scheduler.SchedulerService.java

License:Open Source License

/**
 * Mthode qui dtermine si une instance de planificateur peut etre lanc
 *
 * @param schedulerI//w w w  .ja  v a 2  s.  c o  m
 *       Instance de planificateur
 *
 * @return boolean
 *       True si il est temps de lancer, sinon False
 *
 * @throws AxelorException
 */
private boolean processScheduler(SchedulerInstance schedulerI) throws AxelorException {

    LocalDate date = this.getComputeDate(schedulerI);

    LOG.debug("Date dernire xcution thorique: " + schedulerI.getLastTheoreticalExecutionDate());
    LOG.debug("Date calcul : " + date);
    LOG.debug("Date du jour : " + today);

    if (date != null && (date.equals(today) || date.isBefore(today)))
        return true;

    return false;
}

From source file:com.axelor.apps.hr.service.leave.LeaveService.java

License:Open Source License

public BigDecimal computeLeaveDaysByLeaveRequest(LocalDate fromDate, LocalDate toDate,
        LeaveRequest leaveRequest, Employee employee) throws AxelorException {
    BigDecimal leaveDays = BigDecimal.ZERO;
    WeeklyPlanning weeklyPlanning = employee.getPlanning();
    if (leaveRequest.getDateFrom().equals(fromDate)) {
        leaveDays = leaveDays.add(new BigDecimal(
                this.computeStartDateWithSelect(fromDate, leaveRequest.getStartOnSelect(), weeklyPlanning)));
    }/*from  www . jav  a  2 s .c  om*/
    if (leaveRequest.getDateTo().equals(toDate)) {
        leaveDays = leaveDays.add(new BigDecimal(
                this.computeEndDateWithSelect(toDate, leaveRequest.getEndOnSelect(), weeklyPlanning)));
    }

    LocalDate itDate = new LocalDate(fromDate);
    if (fromDate.isBefore(leaveRequest.getDateFrom()) || fromDate.equals(leaveRequest.getDateFrom())) {
        itDate = new LocalDate(leaveRequest.getDateFrom().plusDays(1));
    }

    while (!itDate.isEqual(leaveRequest.getDateTo()) && !itDate.isAfter(toDate)) {
        leaveDays = leaveDays
                .add(new BigDecimal(weeklyPlanningService.workingDayValue(weeklyPlanning, itDate)));
        if (publicHolidayService.checkPublicHolidayDay(itDate, employee)) {
            leaveDays = leaveDays.subtract(BigDecimal.ONE);
        }
        itDate = itDate.plusDays(1);
    }

    return leaveDays;
}

From source file:com.divudi.bean.common.CommonController.java

public boolean sameDate(Date date1, Date date2) {
    Calendar d1 = Calendar.getInstance();
    d1.setTime(date1);/* w ww  .  j a v  a  2s . c  o  m*/
    DateTime first = new DateTime(date1);
    DateTime second = new DateTime(date2);
    LocalDate firstDate = first.toLocalDate();
    LocalDate secondDate = second.toLocalDate();
    return firstDate.equals(secondDate);
}

From source file:com.excilys.sugadroid.activities.AppointmentsActivity.java

License:Open Source License

private void setDayTextView(LocalDate day) {
    String dayString;//  ww w .  j a v a  2 s.c  o  m
    if (day.equals(new LocalDate())) {
        dayString = getString(R.string.today) + " " + day.toString(getString(R.string.day_date_format));
    } else {
        dayString = day.toString(getString(R.string.day_date_format));
    }

    currentDayText.setText(dayString);
}

From source file:com.excilys.sugadroid.services.impl.ksoap2.AppointmentServicesKsoap2Impl.java

License:Open Source License

@Override
public Map<LocalDate, List<IAppointmentBean>> getAppointmentsInInterval(LocalDate start, LocalDate end)
        throws ServiceException {
    Log.d(TAG, "getAppointmentsInInterval called, days " + start.toString() + " " + end.toString());

    checkLoggedIn();/*from   w w  w  .j a va2s  . c o m*/

    if (start.compareTo(end) > 0) {
        throw new ServiceException("start day should be before or equal to end day");
    }

    boolean version4_5 = sessionBean.isVersion4_5();

    StringBuilder sb = new StringBuilder("meetings_users.meeting_id=meetings.id AND meetings_users.user_id='")
            .append(sessionBean.getUserId()).append("' AND ");

    if (version4_5) {
        sb.append("meetings.date_start>='").append(start.toString("yyyy-MM-dd"))
                .append("' AND meetings.date_start<'").append(end.plusDays(1).toString("yyyy-MM-dd"))
                .append("'");
    } else {
        sb.append("meetings.date_start>='").append(start.toString("yyyy-MM-dd"))
                .append("' AND meetings.date_start<='").append(end.toString("yyyy-MM-dd")).append("'");
    }

    String query = sb.toString();

    SoapObject request = newEntryListRequest();

    request.addProperty("module_name", "Meetings");
    request.addProperty("query", query);
    if (version4_5) {
        request.addProperty("order_by", "meetings.date_start asc, meetings.time_start asc");
    } else {
        request.addProperty("order_by", "meetings.date_start asc");
    }

    request.addProperty("offset", "0");

    List<String> t = new Vector<String>();

    t.add("id");
    t.add("name");
    t.add("date_start");
    if (version4_5) {
        t.add("time_start");
    }

    request.addProperty("select_fields", t);
    request.addProperty("max_results", "1000");
    request.addProperty("deleted", "0");

    List<IAppointmentBean> appointments = new ArrayList<IAppointmentBean>();

    if (version4_5) {
        appointments.addAll(getEntryList(request, AppointmentBeanV4_5.class));
    } else {
        appointments.addAll(getEntryList(request, AppointmentBeanV5.class));
    }

    Map<LocalDate, List<IAppointmentBean>> appointmentsInInterval = new HashMap<LocalDate, List<IAppointmentBean>>();

    appointmentsInInterval.put(start, new ArrayList<IAppointmentBean>());

    LocalDate day = start;

    while (!day.equals(end)) {
        day = day.plusDays(1);
        appointmentsInInterval.put(day, new ArrayList<IAppointmentBean>());
    }

    for (IAppointmentBean appointment : appointments) {
        appointmentsInInterval.get(appointment.getDayStart()).add(appointment);
    }

    return appointmentsInInterval;
}

From source file:com.gst.infrastructure.core.api.JsonCommand.java

License:Apache License

private boolean differenceExists(final LocalDate baseValue, final LocalDate workingCopyValue) {
    boolean differenceExists = false;

    if (baseValue != null) {
        differenceExists = !baseValue.equals(workingCopyValue);
    } else {/*ww  w . j a  va2 s.  com*/
        differenceExists = workingCopyValue != null;
    }

    return differenceExists;
}

From source file:com.gst.integrationtests.common.loans.LoanTransactionHelper.java

License:Apache License

public void checkAccrualTransactionForRepayment(final LocalDate transactionDate, final Float interestPortion,
        final Float feePortion, final Float penaltyPortion, final Integer loanID) {

    ArrayList<HashMap> transactions = (ArrayList<HashMap>) getLoanDetail(this.requestSpec, this.responseSpec,
            loanID, "transactions");
    boolean isTransactionFound = false;
    for (int i = 0; i < transactions.size(); i++) {
        HashMap transactionType = (HashMap) transactions.get(i).get("type");
        boolean isAccrualTransaction = (Boolean) transactionType.get("accrual");

        if (isAccrualTransaction) {
            ArrayList<Integer> accrualEntryDateAsArray = (ArrayList<Integer>) transactions.get(i).get("date");
            LocalDate accrualEntryDate = new LocalDate(accrualEntryDateAsArray.get(0),
                    accrualEntryDateAsArray.get(1), accrualEntryDateAsArray.get(2));

            if (transactionDate.equals(accrualEntryDate)) {
                isTransactionFound = true;
                assertEquals("Mismatch in transaction amounts", interestPortion,
                        Float.valueOf(String.valueOf(transactions.get(i).get("interestPortion"))));
                assertEquals("Mismatch in transaction amounts", feePortion,
                        Float.valueOf(String.valueOf(transactions.get(i).get("feeChargesPortion"))));
                assertEquals("Mismatch in transaction amounts", penaltyPortion,
                        Float.valueOf(String.valueOf(transactions.get(i).get("penaltyChargesPortion"))));
                break;
            }//ww  w  .  j  av a 2s. c  o  m
        }
    }
    assertTrue("No Accrual entries are posted", isTransactionFound);

}

From source file:com.gst.organisation.holiday.service.HolidayUtil.java

License:Apache License

public static LocalDate getRepaymentRescheduleDateToIfHoliday(LocalDate repaymentDate,
        final List<Holiday> holidays) {

    for (final Holiday holiday : holidays) {
        if (repaymentDate.equals(holiday.getFromDateLocalDate())
                || repaymentDate.equals(holiday.getToDateLocalDate())
                || (repaymentDate.isAfter(holiday.getFromDateLocalDate())
                        && repaymentDate.isBefore(holiday.getToDateLocalDate()))) {
            repaymentDate = getRepaymentRescheduleDateIfHoliday(repaymentDate, holidays);
        }/*from ww  w  .  j  av  a  2 s .c  o m*/
    }
    return repaymentDate;
}