List of usage examples for org.joda.time LocalDate isBefore
public boolean isBefore(ReadablePartial partial)
From source file:org.kuali.kpme.core.leaveplan.service.LeavePlanServiceImpl.java
License:Educational Community License
@Override public DateTime getFirstDayOfLeavePlan(String leavePlan, LocalDate asOfDate) { //The only thing this method does is tack on the year of the supplied asOfDate to the calendar year start date. LeavePlan lp = getLeavePlan(leavePlan, asOfDate); int priorYearCutOffMonth = Integer.parseInt(lp.getCalendarYearStartMonth()); int priorYearCutOffDay = Integer.parseInt(lp.getCalendarYearStartDayOfMonth()); LocalDate cutOffDate = asOfDate.withMonthOfYear(priorYearCutOffMonth).withDayOfMonth(priorYearCutOffDay); if (asOfDate.isBefore(cutOffDate)) { cutOffDate = cutOffDate.minusYears(1); }/*from w ww . j a va2 s .c o m*/ return cutOffDate.toDateTimeAtStartOfDay(); }
From source file:org.kuali.kpme.core.util.TKUtils.java
License:Educational Community License
public static long getDaysBetween(LocalDate startDate, LocalDate endDate) { long daysBetween = 0; LocalDate currentDate = startDate; while (currentDate.isBefore(endDate)) { daysBetween++;/* w w w . j ava 2 s .c o m*/ currentDate = currentDate.plusDays(1); } return daysBetween; }
From source file:org.kuali.kpme.tklm.common.CalendarValidationUtil.java
License:Educational Community License
/** * Validate the earn code exists on every day within the date rage. This method is moving to CalendarValidationUtil * @param earnCode/*from w w w. j a va2s .c o m*/ * @param startDateString * @param endDateString * * @return A list of error strings. */ public static List<String> validateEarnCode(String earnCode, String startDateString, String endDateString) { List<String> errors = new ArrayList<String>(); LocalDate tempDate = TKUtils.formatDateTimeStringNoTimezone(startDateString).toLocalDate(); LocalDate localEnd = TKUtils.formatDateTimeStringNoTimezone(endDateString).toLocalDate(); // tempDate and localEnd could be the same day while (!localEnd.isBefore(tempDate)) { if (!ValidationUtils.validateEarnCode(earnCode, tempDate)) { errors.add("Earn Code " + earnCode + " is not available for " + tempDate); break; } tempDate = tempDate.plusDays(1); } return errors; }
From source file:org.kuali.kpme.tklm.leave.summary.service.LeaveSummaryServiceImpl.java
License:Educational Community License
private String getYearKey(LocalDate leaveDate, LeavePlan lp) { String yearKey = Integer.toString(leaveDate.getYear()); LocalDate leavePlanDate = new LocalDate(leaveDate.getYear(), Integer.parseInt(lp.getCalendarYearStartMonth()), Integer.parseInt(lp.getCalendarYearStartDayOfMonth())); if (leaveDate.isBefore(leavePlanDate)) { yearKey = Integer.toString(leaveDate.getYear() - 1); }//from w ww. j a va 2 s. co m return yearKey; }
From source file:org.libreplan.business.costcategories.entities.HourCost.java
License:Open Source License
private boolean isEqualOrAfter(LocalDate date) { return (!date.isBefore(this.getInitDate())); }
From source file:org.libreplan.business.planner.entities.OrderEarnedValueCalculator.java
License:Open Source License
private BigDecimal getValueAt(SortedMap<LocalDate, BigDecimal> map, LocalDate date) { if (map.isEmpty()) { return BigDecimal.ZERO; }/* w w w . j a v a 2 s . c o m*/ BigDecimal result = map.get(date); if (result != null) { return result; } for (LocalDate each : map.keySet()) { if (date.isBefore(each)) { return map.get(each); } } if (date.isAfter(map.lastKey())) { return map.get(map.lastKey()); } return BigDecimal.ZERO; }
From source file:org.libreplan.business.planner.entities.SigmoidFunction.java
License:Open Source License
private List<BigDecimal> daysWithAllocatedHours(ResourceAllocation<?> resourceAllocation) { List<BigDecimal> result = new ArrayList<BigDecimal>(); LocalDate day = new LocalDate(resourceAllocation.getStartDate()); final LocalDate end = resourceAllocation.getEndDate(); while (day.isBefore(end)) { int hoursAllocated = resourceAllocation.getAssignedHours(day, day.plusDays(1)); if (hoursAllocated != 0) { result.add(new BigDecimal(hoursAllocated)); }/*w w w. j ava2s . c om*/ day = day.plusDays(1); } return result; }
From source file:org.libreplan.web.limitingresources.QueueComponent.java
License:Open Source License
private static QueueTask createDivForElement(IDatesMapper datesMapper, LimitingResourceQueueElement queueElement) { final Task task = queueElement.getResourceAllocation().getTask(); final OrderElement order = getRootOrder(task); QueueTask result = new QueueTask(queueElement); String cssClass = "queue-element"; result.setTooltiptext(createTooltiptext(queueElement)); int startPixels = getStartPixels(datesMapper, queueElement); result.setLeft(forCSS(startPixels)); if (startPixels < 0) { cssClass += " truncated-start "; }//from w w w .j av a2 s .c o m int taskWidth = getWidthPixels(datesMapper, queueElement); if ((startPixels + taskWidth) > datesMapper.getHorizontalSize()) { taskWidth = datesMapper.getHorizontalSize() - startPixels; cssClass += " truncated-end "; } else { result.appendChild(generateNonWorkableShade(datesMapper, queueElement)); } result.setWidth(forCSS(taskWidth)); LocalDate deadlineDate = task.getDeadline(); boolean isOrderDeadline = false; if (deadlineDate == null) { Date orderDate = order.getDeadline(); if (orderDate != null) { deadlineDate = LocalDate.fromDateFields(orderDate); isOrderDeadline = true; } } if (deadlineDate != null) { int deadlinePosition = getDeadlinePixels(datesMapper, deadlineDate); if (deadlinePosition < datesMapper.getHorizontalSize()) { Div deadline = new Div(); deadline.setSclass(isOrderDeadline ? "deadline order-deadline" : "deadline"); deadline.setLeft((deadlinePosition - startPixels - DEADLINE_MARK_HALF_WIDTH) + "px"); result.appendChild(deadline); result.appendChild(generateNonWorkableShade(datesMapper, queueElement)); } if (deadlineDate.isBefore(queueElement.getEndDate())) { cssClass += " unmet-deadline "; } } result.setClass(cssClass); result.appendChild(generateCompletionShade(datesMapper, queueElement)); Component progressBar = generateProgressBar(datesMapper, queueElement); if (progressBar != null) { result.appendChild(progressBar); } return result; }
From source file:org.mifos.accounts.business.AccountBO.java
License:Open Source License
private AccountActionDateEntity findInstallmentToUpdate() { List<AccountActionDateEntity> allInstallments = getAllInstallments(); if (allInstallments.size() == 0) { return null; }//from www. j a va 2 s . c om LocalDate currentDate = new LocalDate(); MeetingBO meeting = getMeetingForAccount(); int installmentIndex = 0; AccountActionDateEntity installment = allInstallments.get(installmentIndex); // keep looking at the next installment as long as the current date falls on or // after (!before) the start of the current installment while (installment != null && !currentDate.isBefore( meeting.startDateForMeetingInterval(new LocalDate(installment.getActionDate().getTime())))) { ++installmentIndex; // if we've iterated over all the installments, then just return null if (installmentIndex == allInstallments.size()) { installment = null; } else { installment = allInstallments.get(installmentIndex); } } return installment; }
From source file:org.mifos.accounts.business.AccountBO.java
License:Open Source License
private AccountPaymentEntity findMostRecentPaymentByPaymentDate( List<AccountPaymentEntity> recentAccountPayments) { AccountPaymentEntity mostRecentPayment = null; if (!recentAccountPayments.isEmpty()) { mostRecentPayment = recentAccountPayments.get(0); for (AccountPaymentEntity accountPaymentEntity : recentAccountPayments) { LocalDate paymentDate = new LocalDate(accountPaymentEntity.getPaymentDate()); if ((paymentDate.isAfter(new LocalDate(mostRecentPayment.getPaymentDate())) && paymentDate.isBefore(new LocalDate().plusDays(1))) || (paymentDate.isEqual(new LocalDate(mostRecentPayment.getPaymentDate())) && accountPaymentEntity.getPaymentId() != null && mostRecentPayment.getPaymentId() != null && accountPaymentEntity.getPaymentId() > mostRecentPayment.getPaymentId())) { mostRecentPayment = accountPaymentEntity; }/*ww w. j ava2s.c o m*/ } } return mostRecentPayment; }