List of usage examples for org.joda.time LocalDate isEqual
public boolean isEqual(ReadablePartial partial)
From source file:org.eobjects.analyzer.beans.DateAndTimeAnalyzerColumnDelegate.java
License:Open Source License
public synchronized void run(final Date value, final InputRow row, final int distinctCount) { _numRows += distinctCount;/*from w w w .j av a 2 s .c o m*/ if (value == null) { _annotationFactory.annotate(row, distinctCount, _nullAnnotation); } else { final long timestamp = value.getTime(); for (int i = 0; i < distinctCount; i++) { if (_statistics instanceof DescriptiveStatistics) { ((DescriptiveStatistics) _statistics).addValue(timestamp); } else { ((SummaryStatistics) _statistics).addValue(timestamp); } } LocalDate localDate = new LocalDate(value); LocalTime localTime = new LocalTime(value); if (_minDate == null) { // first non-null value _minDate = localDate; _maxDate = localDate; _minTime = localTime; _maxTime = localTime; } else { if (localDate.isAfter(_maxDate)) { _maxDate = localDate; _annotationFactory.reset(_maxDateAnnotation); } else if (localDate.isBefore(_minDate)) { _minDate = localDate; _annotationFactory.reset(_minDateAnnotation); } if (localTime.isAfter(_maxTime)) { _maxTime = localTime; _annotationFactory.reset(_maxTimeAnnotation); } else if (localTime.isBefore(_minTime)) { _minTime = localTime; _annotationFactory.reset(_minTimeAnnotation); } } if (localDate.isEqual(_maxDate)) { _annotationFactory.annotate(row, distinctCount, _maxDateAnnotation); } if (localDate.isEqual(_minDate)) { _annotationFactory.annotate(row, distinctCount, _minDateAnnotation); } if (localTime.isEqual(_maxTime)) { _annotationFactory.annotate(row, distinctCount, _maxTimeAnnotation); } if (localTime.isEqual(_minTime)) { _annotationFactory.annotate(row, distinctCount, _minTimeAnnotation); } } }
From source file:org.estatio.dom.valuetypes.AbstractInterval.java
License:Apache License
/** * Does this date contain the specified time interval. * /*w w w .j a v a 2 s. co m*/ * @param date * @return */ public boolean contains(final LocalDate date) { if (date == null) { return false; } if (endDate() == null) { if (startDate() == null) { return true; } if (date.isEqual(startDate()) || date.isAfter(startDate())) { return true; } return false; } return asInterval().contains(date.toInterval()); }
From source file:org.killbill.billing.plugin.simpletax.resolving.InvoiceItemEndDateBasedResolver.java
License:Apache License
@Override public TaxCode applicableCodeForItem(Iterable<TaxCode> taxCodes, InvoiceItem item) { DateTimeZone accountTimeZone = account.getTimeZone(); DateTimeZone taxationTimeZone = cfg.getTaxationTimeZone(); LocalDate applicableDate = firstNonNull(item.getEndDate(), item.getStartDate()); final LocalDate taxationDate = taxationTimeZone == null ? applicableDate : convertTimeZone(applicableDate, accountTimeZone, taxationTimeZone); return tryFind(taxCodes, new Predicate<TaxCode>() { @Override/*from w w w . j a v a 2s . com*/ public boolean apply(TaxCode taxCode) { LocalDate startDay = taxCode.getStartingOn(); if ((startDay != null) && taxationDate.isBefore(startDay)) { return false; } LocalDate stopDay = taxCode.getStoppingOn(); if ((stopDay != null) && (taxationDate.isEqual(stopDay) || taxationDate.isAfter(stopDay))) { return false; } return true; } }).orNull(); }
From source file:org.kitodo.production.plugin.opac.pica.PicaPlugin.java
License:Open Source License
/** * The function createResult() creates a Map<String, Object> as result * of getHit(). The map contains the full hit as "fileformat", the docType * as "type" and some bibliographic metadata for Production to be able to * show a short hit display as supposed in * {@link org.goobi.production.plugin.CataloguePlugin.Hit} * * @param docType/*w w w . j av a 2 s. c o m*/ * the DocType of the hit * @param hit * the hit data as JDom Element * @param fileformat * the hit data as Fileformat * @return a Map with the hit */ private static Map<String, Object> createResult(String docType, Element hit, Fileformat fileformat) { final LocalTime DAY_END = new LocalTime(23, 59, 59, 999); Map<String, Object> result = new HashMap<>(20); LocalDate today = new LocalDate(); result.put("fileformat", fileformat); result.put("type", docType); // add some basic metadata String accessed = getElementFieldValue(hit, "208@", "a"); try { LocalDate date = toRecentLocalDate(accessed, today); result.put("accessed", date.toDateTime(date.isEqual(today) ? new LocalTime() : DAY_END).toString()); } catch (RuntimeException e) { logger.error(e); } String lastName = getElementFieldValue(hit, "028A", "a"); if (lastName.equals("")) { lastName = getElementFieldValue(hit, "028A", "l"); } String firstName = getElementFieldValue(hit, "028A", "d"); if (firstName.equals("")) { firstName = getElementFieldValue(hit, "028A", "P"); } String middleTitle = getElementFieldValue(hit, "028A", "c"); String author = lastName + (!firstName.equals("") ? ", " : "") + firstName + (!middleTitle.equals("") ? " " : "") + middleTitle; if (author.equals("")) { author = getElementFieldValue(hit, "028A", "8"); } if (author.equals("")) { String lastName2 = getElementFieldValue(hit, "028C", "a"); if (lastName2.equals("")) { lastName2 = getElementFieldValue(hit, "028C", "l"); } String firstName2 = getElementFieldValue(hit, "028C", "d"); if (firstName2.equals("")) { firstName2 = getElementFieldValue(hit, "028C", "P"); } String middleTitle2 = getElementFieldValue(hit, "028C", "c"); author = lastName2 + (!firstName2.equals("") ? ", " : "") + firstName2 + (!middleTitle2.equals("") ? " " : "") + middleTitle2; } result.put("creator", author); String date = getElementFieldValue(hit, "201B", "0"); try { LocalDate localDate = toRecentLocalDate(date, today); result.put("date", localDate.toString()); } catch (RuntimeException e) { logger.error(e); } result.put("edition", getElementFieldValue(hit, "032@", "a")); result.put("format", docType.startsWith("O") ? "internet" : "monograph"); result.put("number", getElementFieldValue(hit, "036E", "l")); result.put("place", getElementFieldValue(hit, "033A", "p")); result.put("publisher", getElementFieldValue(hit, "033A", "n")); result.put("series", getElementFieldValue(hit, "036E", "a")); String subseries = getElementFieldValue(hit, "021A", "d"); if (subseries == null || subseries.length() == 0) { subseries = getElementFieldValue(hit, "021B", "d"); } if (subseries == null || subseries.length() == 0) { subseries = getElementFieldValue(hit, "027D", "d"); } result.put("subseries", subseries); String title = getElementFieldValue(hit, "021A", "a"); if (title == null || title.length() == 0) { title = getElementFieldValue(hit, "021B", "a"); } if (title == null || title.length() == 0) { title = getElementFieldValue(hit, "027D", "a"); } String titleLong = getElementFieldValue(hit, "021A", "d"); if (titleLong != null && titleLong.length() > 0) { title = title + " : " + titleLong; } result.put("title", title.replaceAll("@", "")); result.put("url", getElementFieldValue(hit, "209R", "a")); result.put("year", getElementFieldValue(hit, "011@", "a")); return result; }
From source file:org.kuali.coeus.common.budget.impl.rate.TrainingStipendRateServiceImpl.java
License:Open Source License
@Override public TrainingStipendRateContract findClosestMatchTrainingStipendRate(Date effectiveDate, String careerLevel, int experienceLevel) { if (effectiveDate == null) { throw new IllegalArgumentException("effectiveDate is null"); }//from w w w .jav a 2 s .c o m if (StringUtils.isBlank(careerLevel)) { throw new IllegalArgumentException("careerLevel is null"); } final Map<String, Object> criteria = new HashMap<>(); criteria.put("careerLevel", careerLevel); criteria.put("experienceLevel", experienceLevel); final Collection<TrainingStipendRate> rates = CollectionUtils.emptyIfNull(businessObjectService .findMatchingOrderBy(TrainingStipendRate.class, criteria, "effectiveDate", false)); for (TrainingStipendRate rate : rates) { if (rate.getEffectiveDate() != null) { final LocalDate limit = LocalDate.fromDateFields(effectiveDate); final LocalDate rateDate = LocalDate.fromDateFields(rate.getEffectiveDate()); if (rateDate.isBefore(limit) || rateDate.isEqual(limit)) { return rate; } } } return null; }
From source file:org.kuali.kpme.tklm.leave.calendar.web.LeaveCalendarAction.java
License:Educational Community License
@Override public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { LeaveCalendarForm leaveCalendarForm = (LeaveCalendarForm) form; String documentId = leaveCalendarForm.getDocumentId(); String principalId = HrContext.getTargetPrincipalId(); CalendarEntry calendarEntry = null;//w w w . j a v a 2 s . c om LeaveCalendarDocument leaveCalendarDocument = null; if (StringUtils.isNotBlank(documentId)) { leaveCalendarDocument = LmServiceLocator.getLeaveCalendarService().getLeaveCalendarDocument(documentId); if (leaveCalendarDocument != null) { calendarEntry = leaveCalendarDocument.getCalendarEntry(); } } else { if (StringUtils.isNotBlank(leaveCalendarForm.getHrCalendarEntryId())) { calendarEntry = HrServiceLocator.getCalendarEntryService() .getCalendarEntry(leaveCalendarForm.getHrCalendarEntryId()); } else { calendarEntry = HrServiceLocator.getCalendarEntryService().getCurrentCalendarDatesForLeaveCalendar( principalId, new LocalDate().toDateTimeAtStartOfDay()); } if (calendarEntry != null) { if (LmServiceLocator.getLeaveCalendarService().shouldCreateLeaveDocument(principalId, calendarEntry)) { leaveCalendarDocument = LmServiceLocator.getLeaveCalendarService() .openLeaveCalendarDocument(principalId, calendarEntry); } else { LeaveCalendarDocumentHeader header = LmServiceLocator.getLeaveCalendarDocumentHeaderService() .getDocumentHeader(principalId, calendarEntry.getBeginPeriodFullDateTime(), calendarEntry.getEndPeriodFullDateTime()); if (header != null) { leaveCalendarDocument = LmServiceLocator.getLeaveCalendarService() .getLeaveCalendarDocument(header.getDocumentId()); } } } } if (calendarEntry != null) { leaveCalendarForm.setHrCalendarEntryId(calendarEntry.getHrCalendarEntryId()); leaveCalendarForm.setCalendarEntry(calendarEntry); leaveCalendarForm.setBeginCalendarEntryDate(calendarEntry.getBeginPeriodDateTime()); leaveCalendarForm .setEndCalendarEntryDate(DateUtils.addMilliseconds(calendarEntry.getEndPeriodDateTime(), -1)); CalendarEntry previousCalendarEntry = HrServiceLocator.getCalendarEntryService() .getPreviousCalendarEntryByCalendarId(calendarEntry.getHrCalendarId(), calendarEntry); if (previousCalendarEntry != null) { LocalDate previousBeginDate = previousCalendarEntry.getBeginPeriodFullDateTime().toLocalDate(); LocalDate previousEndDate = previousCalendarEntry.getEndPeriodFullDateTime().toLocalDate() .minusDays(1); PrincipalHRAttributes principalHRAttributes = HrServiceLocator.getPrincipalHRAttributeService() .getPrincipalCalendar(principalId, previousEndDate); if (principalHRAttributes != null) { LocalDate serviceDate = principalHRAttributes.getServiceLocalDate(); if (serviceDate != null) { if (previousBeginDate.isEqual(serviceDate) || previousBeginDate.isAfter(serviceDate)) { leaveCalendarForm .setPrevHrCalendarEntryId(previousCalendarEntry.getHrCalendarEntryId()); } } else { leaveCalendarForm.setPrevHrCalendarEntryId(previousCalendarEntry.getHrCalendarEntryId()); } } } int planningMonths = ActionFormUtils.getPlanningMonthsForEmployee(principalId); if (planningMonths != 0) { List<CalendarEntry> futureCalendarEntries = HrServiceLocator.getCalendarEntryService() .getFutureCalendarEntries(calendarEntry.getHrCalendarId(), new LocalDate().toDateTimeAtStartOfDay(), planningMonths); if (!futureCalendarEntries.isEmpty()) { CalendarEntry nextCalendarEntry = HrServiceLocator.getCalendarEntryService() .getNextCalendarEntryByCalendarId(calendarEntry.getHrCalendarId(), calendarEntry); CalendarEntry lastFutureCalendarEntry = futureCalendarEntries .get(futureCalendarEntries.size() - 1); if (nextCalendarEntry != null && futureCalendarEntries != null) { DateTime nextCalendarEntryBeginDate = nextCalendarEntry.getBeginPeriodFullDateTime(); DateTime lastFutureCalendarEntryBeginDate = lastFutureCalendarEntry .getBeginPeriodFullDateTime(); if (nextCalendarEntryBeginDate.isBefore(lastFutureCalendarEntryBeginDate) || nextCalendarEntryBeginDate.isEqual(lastFutureCalendarEntryBeginDate)) { leaveCalendarForm.setNextHrCalendarEntryId(nextCalendarEntry.getHrCalendarEntryId()); } } } } setCalendarFields(request, leaveCalendarForm); } else { EntityNamePrincipalName entityNamePrincipalName = KimApiServiceLocator.getIdentityService() .getDefaultNamesForPrincipalId(principalId); GlobalVariables.getMessageMap().putError(KRADConstants.GLOBAL_ERRORS, "error.missing.leaveCalendar", entityNamePrincipalName.getPrincipalName()); } ActionForward actionForward = super.execute(mapping, form, request, response); if (calendarEntry != null) { List<Assignment> assignments = HrServiceLocator.getAssignmentService() .getAssignmentsByCalEntryForLeaveCalendar(principalId, calendarEntry); List<String> assignmentKeys = new ArrayList<String>(); for (Assignment assignment : assignments) { assignmentKeys.add(assignment.getAssignmentKey()); } if (leaveCalendarDocument != null) { leaveCalendarForm.setLeaveCalendarDocument(leaveCalendarDocument); leaveCalendarForm.setDocumentId(leaveCalendarDocument.getDocumentId()); leaveCalendarForm.setAssignmentDescriptions(leaveCalendarDocument.getAssignmentDescriptions()); } else { leaveCalendarForm.setAssignmentDescriptions(HrServiceLocator.getAssignmentService() .getAssignmentDescriptionsForAssignments(assignments)); } if (HrServiceLocator.getHRPermissionService().canViewLeaveTabsWithNEStatus()) { if (LocalDate.now().isBefore(calendarEntry.getEndPeriodFullDateTime().toLocalDate()) || LocalDate.now().isEqual(calendarEntry.getEndPeriodFullDateTime().toLocalDate())) { setDocEditable(leaveCalendarForm, leaveCalendarDocument); } } else { setDocEditable(leaveCalendarForm, leaveCalendarDocument); } runAccrualService(leaveCalendarForm); List<LeaveBlock> leaveBlocks = getLeaveBlocks(principalId, calendarEntry, leaveCalendarDocument, assignmentKeys); setLeaveBlocks(leaveCalendarForm, principalId, leaveBlocks, assignmentKeys); setLeaveSummary(leaveCalendarForm); setMessages(leaveCalendarForm, leaveBlocks); setBlockSubmittable(leaveCalendarForm, leaveCalendarDocument); } return actionForward; }
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; }/*from w w w. ja v a2 s.c om*/ } } return mostRecentPayment; }
From source file:org.mifos.accounts.business.AccountBO.java
License:Open Source License
public List<AccountActionDateEntity> getDetailsOfInstallmentsInArrearsOn(LocalDate asOf) { List<AccountActionDateEntity> installmentsInArrears = new ArrayList<AccountActionDateEntity>(); Set<AccountActionDateEntity> accountActionDates = getAccountActionDates(); if (accountActionDates != null && !accountActionDates.isEmpty()) { for (AccountActionDateEntity accountAction : accountActionDates) { LocalDate installmentDate = new LocalDate(accountAction.getActionDate()); if (asOf.isAfter(installmentDate) && !accountAction.isPaid() || asOf.isEqual(installmentDate)) { installmentsInArrears.add(accountAction); }//from w ww. j a v a 2 s . c om } } return installmentsInArrears; }
From source file:org.mifos.accounts.savings.business.SavingsBO.java
License:Open Source License
public AccountPaymentEntity findMostRecentDepositOrWithdrawalByDate() { AccountPaymentEntity mostRecentPayment = null; if (!this.accountPayments.isEmpty()) { for (AccountPaymentEntity accountPaymentEntity : this.accountPayments) { if (mostRecentPayment == null && accountPaymentEntity.isSavingsDepositOrWithdrawal()) { mostRecentPayment = accountPaymentEntity; } else if (mostRecentPayment != null) { 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()) && accountPaymentEntity.isSavingsDepositOrWithdrawal()) { mostRecentPayment = accountPaymentEntity; }// w w w. jav a 2s . c o m } } } return mostRecentPayment; }
From source file:org.mifos.accounts.savings.business.SavingsBO.java
License:Open Source License
@Override public boolean isTrxnDateValid(Date trxnDate, Date lastMeetingDate, boolean repaymentIndependentOfMeetingEnabled) { LocalDate transactionLocalDate = new LocalDate(trxnDate); LocalDate today = new LocalDate(); if (AccountingRules.isBackDatedTxnAllowed()) { if (repaymentIndependentOfMeetingEnabled) { Date activationDate = this.getActivationDate(); return trxnDate.compareTo(DateUtils.getDateWithoutTimeStamp(activationDate)) >= 0; }/*from ww w . j ava 2 s .c om*/ InterestScheduledEvent postingEvent = new SavingsInterestScheduledEventFactory() .createScheduledEventFrom(this.getInterestPostingMeeting()); LocalDate nextPostingDate = new LocalDate(this.nextIntPostDate); LocalDate currentPostingPeriodStartDate = postingEvent .findFirstDateOfPeriodForMatchingDate(nextPostingDate); if (getInterestPostingMeeting().isDaily()) { if (lastIntPostDate == null) { currentPostingPeriodStartDate = new LocalDate(activationDate); } else { currentPostingPeriodStartDate = new LocalDate(lastIntPostDate).plusDays(1); } } // FIXME throw an exception with the correct reason instead of returning false if (transactionLocalDate.isBefore(currentPostingPeriodStartDate)) { return false; } LocalDate activationDate = new LocalDate(this.activationDate); if (lastMeetingDate != null) { LocalDate meetingDate = new LocalDate(lastMeetingDate); return (transactionLocalDate.isAfter(meetingDate) || transactionLocalDate.isEqual(meetingDate)) && (transactionLocalDate.isAfter(activationDate) || transactionLocalDate.isEqual(activationDate)); } return (transactionLocalDate.isAfter(activationDate) || transactionLocalDate.isEqual(activationDate)) && (transactionLocalDate.isBefore(today) || transactionLocalDate.isEqual(today)); } return transactionLocalDate.isEqual(today); }