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:org.libreplan.business.planner.entities.visitors.CalculateFinishedTasksLagInCompletionVisitor.java

License:Open Source License

public void visit(Task task) {
    if (task.isFinished()) {
        List<WorkReportLine> workReportLines = task.getOrderElement().getWorkReportLines(true);
        if (workReportLines.size() > 0) {
            WorkReportLine last = getLastWorkReportLineWithEffortDurationNoZero(workReportLines);
            if (last != null) {
                LocalDate lastRLDate = LocalDate.fromDateFields(last.getDate());
                LocalDate endDate = task.getEndAsLocalDate();
                deviations.add((double) Days.daysBetween(endDate, lastRLDate).getDays());
            }/*from w  w  w  . ja  v a 2  s . c om*/
        }
    }
}

From source file:org.libreplan.business.templates.entities.OrderElementTemplate.java

License:Open Source License

private static Days daysBetween(Date start, Date end) {
    if (start == null || end == null) {
        return null;
    }/* w w w. ja va 2s  . c om*/

    return Days.daysBetween(asDateTime(start), asDateTime(end));
}

From source file:org.libreplan.business.workingday.IntraDayDate.java

License:Open Source License

public int numberOfDaysUntil(IntraDayDate end) {
    Validate.isTrue(compareTo(end) <= 0);
    Days daysBetween = Days.daysBetween(getDate(), end.getDate());
    if (getEffortDuration().compareTo(end.getEffortDuration()) <= 0) {
        return daysBetween.getDays();
    } else {/*from w  w  w .  j  a  v  a2s  . c  om*/
        return daysBetween.getDays() - 1;
    }
}

From source file:org.libreplan.business.workingday.IntraDayDate.java

License:Open Source License

/**
 * Returns the {@link EffortDuration} until {@code end} considering 8h per
 * day of effort./*ww  w.ja v a2 s .c  o m*/
 *
 * @param end
 * @return The {@link EffortDuration} until {@code end}
 */
public EffortDuration effortUntil(IntraDayDate end) {
    Validate.isTrue(compareTo(end) <= 0);
    int days = Days.daysBetween(getDate(), end.getDate()).getDays();

    EffortDuration result = EffortDuration.hours(days * 8);

    if (!getEffortDuration().isZero()) {
        result = result.minus(EffortDuration.hours(8));
        result = result.plus(EffortDuration.hours(8).minus(getEffortDuration()));
    }

    if (!end.getEffortDuration().isZero()) {
        result = result.plus(end.getEffortDuration());
    }

    return result;
}

From source file:org.libreplan.web.dashboard.DashboardModel.java

License:Open Source License

private void calculateMarginWithDeadLine() {
    if (this.getRootTask() == null) {
        throw new RuntimeException("Root task is null");
    }// ww w  .  j  ava  2s  .  c o  m

    if (this.currentOrder.getDeadline() == null) {
        this.marginWithDeadLine = null;
        return;
    }

    TaskGroup rootTask = getRootTask();
    LocalDate endDate = TaskElement.maxDate(rootTask.getChildren()).asExclusiveEnd();
    Days orderDuration = Days.daysBetween(TaskElement.minDate(rootTask.getChildren()).getDate(), endDate);

    LocalDate deadLineAsLocalDate = LocalDate.fromDateFields(currentOrder.getDeadline());
    Days deadlineOffset = Days.daysBetween(endDate, deadLineAsLocalDate.plusDays(1));

    BigDecimal outcome = new BigDecimal(deadlineOffset.getDays(), MathContext.DECIMAL32);

    this.marginWithDeadLine = orderDuration.getDays() != 0
            ? outcome.divide(new BigDecimal(orderDuration.getDays()), 8, BigDecimal.ROUND_HALF_EVEN)
            : new BigDecimal(Days.daysBetween(rootTask.getStartAsLocalDate(), deadLineAsLocalDate.plusDays(1))
                    .getDays());
}

From source file:org.libreplan.web.dashboard.DashboardModel.java

License:Open Source License

private int daysBetween(LocalDate start, LocalDate end) {
    return Days.daysBetween(start, end).getDays();
}

From source file:org.libreplan.web.montecarlo.MonteCarloTask.java

License:Open Source License

public static BigDecimal calculateRealDurationFor(MonteCarloTask task, BigDecimal daysDuration) {
    LocalDate start = task.getStartDate();
    Validate.notNull(start);/*from w  ww  .  j  a v a  2s  . c  o  m*/
    LocalDate end = calculateEndDateFor(task, daysDuration);
    Days daysBetween = Days.daysBetween(start, end);

    return BigDecimal.valueOf(daysBetween.getDays());
}

From source file:org.libreplan.web.planner.chart.ChartFiller.java

License:Open Source License

private void fillValues(SortedMap<LocalDate, BigDecimal> map, LocalDate firstDay, LocalDate lastDay,
        BigDecimal firstValue, BigDecimal lastValue) {

    Integer days = Days.daysBetween(firstDay, lastDay).getDays();
    if (days > 0) {
        BigDecimal ammount = lastValue.subtract(firstValue);
        BigDecimal ammountPerDay = ammount.setScale(2, RoundingMode.DOWN).divide(new BigDecimal(days),
                RoundingMode.DOWN);

        BigDecimal value = firstValue.setScale(2, RoundingMode.DOWN);
        for (LocalDate day = firstDay; day.compareTo(lastDay) <= 0; day = day.plusDays(1)) {
            map.put(day, value);// w  ww .  j  av  a 2 s . co m
            value = value.add(ammountPerDay);
        }
    }
}

From source file:org.lightjason.agentspeak.action.buildin.datetime.CDaysBetween.java

License:LGPL

@Override
protected final Stream<?> apply(final Stream<List<Instant>> p_datetime) {
    return p_datetime.map(i -> Days.daysBetween(i.get(0), i.get(1))).mapToLong(Days::getDays).boxed();
}

From source file:org.lightjason.agentspeak.action.builtin.datetime.CDaysBetween.java

License:LGPL

@Nonnull
@Override//from  w w  w . j a v  a2s  .com
protected final Stream<?> apply(@Nonnull final Stream<List<Instant>> p_datetime) {
    return p_datetime.map(i -> Days.daysBetween(i.get(0), i.get(1))).mapToDouble(Days::getDays).boxed();
}