Example usage for org.joda.time LocalDate isAfter

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

Introduction

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

Prototype

public boolean isAfter(ReadablePartial partial) 

Source Link

Document

Is this partial later than the specified partial.

Usage

From source file:ar.com.wolox.commons.base.datetime.LocalDateRange.java

License:Apache License

/**
 * Creates the LocalDateRangeProvider./*w  w w  . j  ava  2s  .c o  m*/
 *
 * @param start
 * @param end
 */
public LocalDateRange(@NotNull final LocalDate start, @NotNull final LocalDate end) {
    if (start == null) {
        throw new IllegalArgumentException("start cannot be null");
    }

    if (end == null) {
        throw new IllegalArgumentException("end cannot be null");
    }

    if (start.isAfter(end)) {
        throw new IllegalArgumentException("start date must be before or equal to end date");
    }

    this.start = start;
    this.end = end;
}

From source file:at.jclehner.rxdroid.db.Entries.java

License:Open Source License

public static boolean willExpireSoon(Drug drug, Date date) {
    if (!drug.isActive() || drug.getRefillSize() == 0)
        return false;

    final LocalDate expirationDate = drug.getExpiryDate();
    if (expirationDate == null)
        return false;

    final LocalDate scheduleEnd = drug.getScheduleEndDate();
    if (scheduleEnd != null && expirationDate.isAfter(scheduleEnd))
        return false;

    final int minSupplyDays = Settings.getStringAsInt(Settings.Keys.LOW_SUPPLY_THRESHOLD, 10);
    if (minSupplyDays == 0)
        return false;

    return LocalDate.fromDateFields(date).plusDays(minSupplyDays).isAfter(expirationDate);
}

From source file:br.com.moonjava.flight.util.VerifierString.java

License:Apache License

public static boolean isValidate(String word) {
    try {// w w  w  . j  av a 2s .  c  om
        boolean validate = false;
        LocalDate now = new LocalDate();
        String year = word.substring(3, 7);
        String month = word.substring(0, 2);

        LocalDate date = new LocalDate().withYear(Integer.parseInt(year))
                .withMonthOfYear(Integer.parseInt(month));

        if (date.isAfter(now) || date.isEqual(now)) {
            Pattern pattern = Pattern.compile("(0[1-9]|1[012])/((19|20)\\d\\d)");
            Matcher matcher = pattern.matcher(word);
            validate = matcher.find();
        }

        return validate;
    } catch (IllegalFieldValueException e) {
        return false;
    }
}

From source file:com.app.gpo.services.OrderItemAutoChangeStatus.java

License:Open Source License

@Scheduled(cron = "0 30 * * * ?")
public void scheduleChangeStatus() {
    // something that should execute on weekdays only
    logger.info("Searching for order items to change status");

    LocalDate today = new LocalDate();
    LocalDate threDaysAgo = today.minusDays(3);

    OrderStatus orderStatus = orderStatusService.findIdByName("W toku");
    OrderStatus orderStatusNew = orderStatusService.findIdByName("Zakoczone");

    List<OrderItem> orderItemList = orderItemService.findByOrderStatus(orderStatus);
    Iterator<OrderItem> orderItem = orderItemList.iterator();
    while (orderItem.hasNext()) {
        OrderItem oI = orderItem.next();
        LocalDate orderStatusDate = new LocalDate(oI.getorderStatusDate());
        boolean olderThen3 = threDaysAgo.isAfter(orderStatusDate);
        //logger.info("Order item "+oI.getorderNumber()+" has status change date: "+oI.getorderStatusDate());
        if (olderThen3) {
            logger.info("Order item " + oI.getorderNumber() + " status has been changed to 'Zakoczone'.");
            oI.setorderStatus(orderStatusNew);
            orderItemService.update(oI);
        }/*ww  w  . ja  va 2 s . c o  m*/
    }
}

From source file:com.axelor.apps.account.service.BudgetService.java

License:Open Source License

public List<BudgetLine> updateLines(Budget budget) {
    if (budget.getBudgetLineList() != null && !budget.getBudgetLineList().isEmpty()) {
        for (BudgetLine budgetLine : budget.getBudgetLineList()) {
            budgetLine.setAmountRealized(BigDecimal.ZERO);
        }// www. j ava2 s.  c  om
        List<BudgetDistribution> budgetDistributionList = Beans.get(BudgetDistributionRepository.class).all()
                .filter("self.budget.id = ?1 AND (self.invoiceLine.invoice.statusSelect = ?2 OR self.invoiceLine.invoice.statusSelect = ?3)",
                        budget.getId(), InvoiceRepository.STATUS_VALIDATED, InvoiceRepository.STATUS_VENTILATED)
                .fetch();
        for (BudgetDistribution budgetDistribution : budgetDistributionList) {
            LocalDate orderDate = budgetDistribution.getInvoiceLine().getInvoice().getInvoiceDate();
            if (orderDate != null) {
                for (BudgetLine budgetLine : budget.getBudgetLineList()) {
                    LocalDate fromDate = budgetLine.getFromDate();
                    LocalDate toDate = budgetLine.getToDate();
                    if ((fromDate.isBefore(orderDate) || fromDate.isEqual(orderDate))
                            && (toDate.isAfter(orderDate) || toDate.isEqual(orderDate))) {
                        budgetLine.setAmountRealized(
                                budgetLine.getAmountRealized().add(budgetDistribution.getAmount()));
                        break;
                    }
                }
            }
        }
    }
    return budget.getBudgetLineList();
}

From source file:com.axelor.apps.account.service.BudgetService.java

License:Open Source License

public List<BudgetLine> generatePeriods(Budget budget) {

    if (budget.getBudgetLineList() != null && !budget.getBudgetLineList().isEmpty()) {
        List<BudgetLine> budgetLineList = budget.getBudgetLineList();
        budgetLineList.clear();//ww  w  .  ja  v a 2  s . c o m
    }

    List<BudgetLine> budgetLineList = new ArrayList<BudgetLine>();
    Integer duration = budget.getPeriodDurationSelect();
    LocalDate fromDate = budget.getFromDate();
    LocalDate toDate = budget.getToDate();
    LocalDate budgetLineToDate = fromDate;
    Integer budgetLineNumber = 1;

    while (budgetLineToDate.isBefore(toDate)) {
        if (budgetLineNumber != 1)
            fromDate = fromDate.plusMonths(duration);
        budgetLineToDate = fromDate.plusMonths(duration).minusDays(1);
        if (budgetLineToDate.isAfter(toDate))
            budgetLineToDate = toDate;
        if (fromDate.isAfter(toDate))
            continue;
        BudgetLine budgetLine = new BudgetLine();
        budgetLine.setFromDate(fromDate);
        budgetLine.setToDate(budgetLineToDate);
        budgetLine.setBudget(budget);
        budgetLine.setAmountExpected(budget.getAmountForGeneration());
        budgetLineList.add(budgetLine);
        budgetLineNumber++;
    }
    return budgetLineList;
}

From source file:com.axelor.apps.account.service.debtrecovery.ReminderService.java

License:Open Source License

/**
 * Fonction qui rcupre la plus ancienne date d'chance d'une liste de lignes d'criture
 * @param moveLineList/*from  www . j  av  a2 s  . c o m*/
 *          Une liste de lignes d'criture
 * @return
 *          la plus ancienne date d'chance
 */
public LocalDate getOldDateMoveLine(List<MoveLine> moveLineList) {
    LocalDate minMoveLineDate = new LocalDate();

    if (moveLineList != null && !moveLineList.isEmpty()) {
        for (MoveLine moveLine : moveLineList) {
            if (minMoveLineDate.isAfter(moveLine.getDueDate())) {
                minMoveLineDate = moveLine.getDueDate();
            }
        }
    } else {
        minMoveLineDate = null;
    }
    return minMoveLineDate;
}

From source file:com.axelor.apps.account.service.debtrecovery.ReminderService.java

License:Open Source License

/**
 * Fonction qui rcupre la plus rcente date entre deux date
 * @param date1//from   w ww .  j  av  a2 s  . c  o m
 *          Une date
 * @param date2
 *          Une date
 * @return minDate
 *          La plus ancienne date
 */
public LocalDate getLastDate(LocalDate date1, LocalDate date2) {
    LocalDate minDate = new LocalDate();
    if (date1 != null && date2 != null) {
        if (date1.isAfter(date2)) {
            minDate = date1;
        } else {
            minDate = date2;
        }
    } else if (date1 != null) {
        minDate = date1;
    } else if (date2 != null) {
        minDate = date2;
    } else {
        minDate = null;
    }
    return minDate;
}

From source file:com.axelor.apps.account.service.PaymentScheduleService.java

License:Open Source License

public LocalDate getMostOldDatePaymentScheduleLine(List<PaymentScheduleLine> paymentScheduleLineList) {
    LocalDate minPaymentScheduleLineDate = new LocalDate();

    if (paymentScheduleLineList != null && !paymentScheduleLineList.isEmpty()) {
        for (PaymentScheduleLine paymentScheduleLine : paymentScheduleLineList) {
            if (minPaymentScheduleLineDate.isAfter(paymentScheduleLine.getScheduleDate())) {
                minPaymentScheduleLineDate = paymentScheduleLine.getScheduleDate();
            }/* w  w  w  .j ava2  s.com*/
        }
    } else {
        minPaymentScheduleLineDate = null;
    }
    return minPaymentScheduleLineDate;
}

From source file:com.axelor.apps.account.service.YearService.java

License:Open Source License

public List<Period> generatePeriods(Year year) {

    List<Period> periods = new ArrayList<Period>();
    Integer duration = year.getPeriodDurationSelect();
    LocalDate fromDate = year.getFromDate();
    LocalDate toDate = year.getToDate();
    LocalDate periodToDate = fromDate;
    Integer periodNumber = 1;/*from  www .  j  a  v a 2s.co  m*/

    while (periodToDate.isBefore(toDate)) {
        if (periodNumber != 1)
            fromDate = fromDate.plusMonths(duration);
        periodToDate = fromDate.plusMonths(duration).minusDays(1);
        if (periodToDate.isAfter(toDate))
            periodToDate = toDate;
        if (fromDate.isAfter(toDate))
            continue;
        Period period = new Period();
        period.setFromDate(fromDate);
        period.setToDate(periodToDate);
        period.setYear(year);
        period.setName(String.format("%02d", periodNumber) + "/" + year.getCode());
        period.setCode(
                String.format("%02d", periodNumber) + "/" + year.getCode() + "_" + year.getCompany().getCode());
        period.setCompany(year.getCompany());
        period.setStatusSelect(year.getStatusSelect());
        periods.add(period);
        periodNumber++;
    }
    return periods;
}