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:org.devmaster.elasticsearch.index.mapper.Recurring.java

License:Apache License

public boolean occurBetween(final LocalDate start, final LocalDate end) throws ParseException {
    LocalDate startDate = new LocalDate(this.startDate);
    LocalDate endDate = this.endDate != null ? new LocalDate(this.endDate) : null;

    if (rrule != null) {

        LocalDateIterator it = LocalDateIteratorFactory.createLocalDateIterator(rrule, startDate, false);
        it.advanceTo(start);//w  w w.j av a  2  s  .c  o m

        if (it.hasNext()) {
            LocalDate nextOccurrence = it.next();
            return nextOccurrence != null && !nextOccurrence.isBefore(start) && !nextOccurrence.isAfter(end);
        } else {
            return false;
        }

    } else if (endDate != null) {

        return !start.isBefore(startDate) && !end.isAfter(endDate);

    }

    return !startDate.isBefore(start) && !startDate.isAfter(end);
}

From source file:org.devmaster.elasticsearch.index.mapper.Recurring.java

License:Apache License

public LocalDate getNextOccurrence(LocalDate date) throws ParseException {

    final LocalDate start = new LocalDate(this.startDate);

    if (this.rrule != null) {
        LocalDateIterator it = LocalDateIteratorFactory.createLocalDateIterator(rrule, start.minusDays(1),
                false);/*from   w  w  w.j  a va  2s . c  om*/
        it.advanceTo(date);
        return it.hasNext() ? it.next() : null;
    } else if (this.endDate == null) {
        return !date.isAfter(start) ? start : null;
    } else {
        LocalDate end = new LocalDate(this.endDate);
        return !date.isAfter(end) ? start : null;
    }
}

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  ww . j a v  a  2 s . co  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.app.interactivemap.InteractiveMapForFixedAssetService.java

License:Apache License

private String getLeaseName(Unit unit) {
    LocalDate today = LocalDate.now();
    List<Occupancy> occupancyList = occupancies.occupancies(unit);
    for (Occupancy occupancy : occupancyList) {
        LocalDate startDate = occupancy.getStartDate();
        LocalDate endDate = occupancy.getEndDate();
        if ((startDate == null || today.isAfter(startDate)) && (endDate == null || today.isBefore(endDate))) {
            Lease lease = occupancy.getLease();
            return lease.getName();
        }/*from www .  j  ava2  s  .c om*/
    }
    return null;
}

From source file:org.estatio.dom.agreement.Agreement.java

License:Apache License

public String validateNewRole(final AgreementRoleType art, final Party newParty, final LocalDate startDate,
        final LocalDate endDate) {

    Party currentParty = findCurrentOrMostRecentParty(art);
    if (currentParty != null
            && !Objects.equal(currentParty.getApplicationTenancy(), newParty.getApplicationTenancy())) {
        return "The application level of the new party must be the same as that of the current party";
    }// w w w.ja  va2 s.  c o  m

    if (startDate != null && endDate != null && startDate.isAfter(endDate)) {
        return "End date cannot be earlier than start date";
    }
    if (!Sets.filter(getRoles(), art.matchingRole()).isEmpty()) {
        return "Add a successor/predecessor to existing agreement role";
    }
    return null;
}

From source file:org.estatio.dom.agreement.AgreementRole.java

License:Apache License

public String validateAddCommunicationChannel(final AgreementRoleCommunicationChannelType type,
        final CommunicationChannel communicationChannel, final LocalDate startDate, final LocalDate endDate) {
    if (startDate != null && endDate != null && startDate.isAfter(endDate)) {
        return "End date cannot be earlier than start date";
    }//from   w ww  .j  a v  a2s .c o m
    if (!Sets.filter(getCommunicationChannels(), type.matchingCommunicationChannel()).isEmpty()) {
        return "Add a successor/predecessor from existing communication channel";
    }
    final SortedSet<CommunicationChannel> partyChannels = communicationChannelContributions
            .communicationChannels(getParty());
    if (!partyChannels.contains(communicationChannel)) {
        return "Communication channel must be one of those of this party";
    }
    return null;
}

From source file:org.estatio.dom.asset.FixedAsset.java

License:Apache License

public String validateNewRole(final FixedAssetRoleType type, final Party party, final LocalDate startDate,
        final LocalDate endDate) {
    if (startDate != null && endDate != null && startDate.isAfter(endDate)) {
        return "End date cannot be earlier than start date";
    }//from   w  w w.ja v a2 s  .c o m
    if (!Sets.filter(getRoles(), type.matchingRole()).isEmpty()) {
        return "Add a successor/predecessor from existing role";
    }
    return null;
}

From source file:org.estatio.dom.project.ProgramRolesContributions.java

License:Apache License

public String validateNewProgramRole(final Program program, final ProgramRoleType type, final Party party,
        final LocalDate startDate, final LocalDate endDate) {
    if (startDate != null && endDate != null && startDate.isAfter(endDate)) {
        return "End date cannot be earlier than start date";
    }//from   w w  w  . jav  a  2  s. c o  m

    LocalDateInterval newInterval = new LocalDateInterval(startDate, endDate);
    for (Iterator<ProgramRole> it = programRoles.findByProgram(program).iterator(); it.hasNext();) {

        ProgramRole pr = it.next();
        if (pr.getParty().equals(party) && pr.getType().equals(type)) {

            LocalDateInterval oldInterval = new LocalDateInterval(pr.getStartDate(), pr.getEndDate());

            if (newInterval.overlaps(oldInterval)) {
                return "Same party, same role, cannot have overlapping period";
            }

        }

    }

    return null;
}

From source file:org.estatio.dom.project.Project.java

License:Apache License

public String validateUpdateDates(final LocalDate startDate, final LocalDate endDate) {

    if (startDate.isAfter(endDate)) {
        return "Start date cannot be later than End date";
    }/*from  w  ww .  j ava2 s. co  m*/

    return null;
}

From source file:org.estatio.dom.project.ProjectRolesContributions.java

License:Apache License

public String validateNewProjectRole(final Project project, final ProjectRoleType type, final Party party,
        final LocalDate startDate, final LocalDate endDate) {
    if (startDate != null && endDate != null && startDate.isAfter(endDate)) {
        return "End date cannot be earlier than start date";
    }/*from  w w w . ja  v  a 2s . co m*/

    LocalDateInterval newInterval = new LocalDateInterval(startDate, endDate);
    for (Iterator<ProjectRole> it = projectRoles.findByProject(project).iterator(); it.hasNext();) {

        ProjectRole pr = it.next();
        if (pr.getParty().equals(party) && pr.getType().equals(type)) {

            LocalDateInterval oldInterval = new LocalDateInterval(pr.getStartDate(), pr.getEndDate());

            if (newInterval.overlaps(oldInterval)) {
                return "Same party, same role, cannot have overlapping period";
            }

        }

    }

    return null;
}