Example usage for org.joda.time LocalDate isBefore

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

Introduction

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

Prototype

public boolean isBefore(ReadablePartial partial) 

Source Link

Document

Is this partial earlier than the specified partial.

Usage

From source file:org.apereo.portlet.hr.model.timereporting.PayPeriodDailyLeaveTimeSummary.java

License:Apache License

public PayPeriodDailyLeaveTimeSummary(LocalDate payPeriodStart, LocalDate payPeriodEnd,
        List<JobDescription> jobDescriptions, Set<Integer> displayOnlyJobCodes,
        List<TimePeriodEntry> timePeriodEntries) {
    if (payPeriodEnd.isBefore(payPeriodStart)) {
        throw new IllegalArgumentException("Pay period end cannot be earlier than pay period start");
    }//from w  w w  .ja v  a 2 s . co  m
    this.payPeriodStart = payPeriodStart;
    this.payPeriodEnd = payPeriodEnd;
    this.jobDescriptions = jobDescriptions;
    this.displayOnlyJobCodes = displayOnlyJobCodes;
    this.timePeriodEntries = timePeriodEntries;
}

From source file:org.datacleaner.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  a2s . c  om*/
    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.resetAnnotation(_maxDateAnnotation);
            } else if (localDate.isBefore(_minDate)) {
                _minDate = localDate;
                _annotationFactory.resetAnnotation(_minDateAnnotation);
            }

            if (localTime.isAfter(_maxTime)) {
                _maxTime = localTime;
                _annotationFactory.resetAnnotation(_maxTimeAnnotation);
            } else if (localTime.isBefore(_minTime)) {
                _minTime = localTime;
                _annotationFactory.resetAnnotation(_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.devmaster.elasticsearch.index.mapper.Recurring.java

License:Apache License

public boolean hasOccurrencesAt(final LocalDate date) throws ParseException {
    if (this.rrule != null) {
        LocalDate end = date.plusDays(1);
        LocalDateIterator it = LocalDateIteratorFactory.createLocalDateIterator(rrule,
                new LocalDate(this.startDate), false);
        it.advanceTo(date);/*w ww .j  a  v a  2 s.c  o m*/
        return it.hasNext() && it.next().isBefore(end);
    } else if (this.endDate != null) {
        LocalDate start = new LocalDate(this.startDate);
        LocalDate end = new LocalDate(this.endDate);
        return !date.isBefore(start) && !date.isAfter(end);
    } else {
        return new LocalDate(this.startDate).isEqual(date);
    }
}

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);//from  www. j ava 2 s .c  om

        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.efaps.esjp.ui.dashboard.StatusPanel_Base.java

License:Apache License

@Override
public CharSequence getHtmlSnipplet() throws EFapsException {
    CharSequence ret;/*  w w w  .j  a v  a2 s . c  o  m*/
    if (isCached()) {
        ret = getFromCache();
    } else {
        final Map<LocalDate, Set<Long>> values = new TreeMap<>();

        final DateTime startDate = new DateTime().minusDays(getDays());

        final QueryBuilder queryBldr = new QueryBuilder(CICommon.HistoryLogin);
        queryBldr.addWhereAttrGreaterValue(CICommon.HistoryLogin.Created, startDate);
        queryBldr.addOrderByAttributeAsc(CICommon.HistoryLogin.Created);
        final MultiPrintQuery multi = queryBldr.getPrint();
        multi.addAttribute(CICommon.HistoryLogin.Created, CICommon.HistoryLogin.GeneralInstanceLink);
        multi.executeWithoutAccessCheck();
        while (multi.next()) {
            final DateTime created = multi.getAttribute(CICommon.HistoryLogin.Created);
            final LocalDate date = created.toLocalDate();
            final Long gId = multi.getAttribute(CICommon.HistoryLogin.GeneralInstanceLink);
            Set<Long> set;
            if (values.containsKey(date)) {
                set = values.get(date);
            } else {
                set = new HashSet<>();
                values.put(date, set);
            }
            set.add(gId);
        }

        final LineChart chart = new LineChart().setLineLayout(LineLayout.LINES).setWidth(getWidth())
                .setHeight(getHeight());
        final String title = getTitle();
        if (title != null && !title.isEmpty()) {
            chart.setTitle(getTitle());
        }
        final Axis xAxis = new Axis().setName("x").addConfig("rotation", "-45");
        chart.addAxis(xAxis);

        final Serie<Data> serie = new Serie<Data>();
        serie.setName("Usuarios").setMouseIndicator(new MouseIndicator());
        ;
        chart.addSerie(serie);

        final List<Map<String, Object>> labels = new ArrayList<>();
        int idx = 1;
        LocalDate current = startDate.toLocalDate();
        while (current.isBefore(new DateTime().plusDays(1).toLocalDate())) {
            int yVal;
            if (values.containsKey(current)) {
                yVal = values.get(current).size();
            } else {
                yVal = 0;
            }
            final Data data = new Data();
            serie.addData(data);
            data.setYValue(yVal).setXValue(idx);
            final Map<String, Object> labelMap = new HashMap<>();
            labelMap.put("value", idx);
            labelMap.put("text", Util
                    .wrap4String(current.toString(getDateFormat(), Context.getThreadContext().getLocale())));
            labels.add(labelMap);
            idx++;
            current = current.plusDays(1);
        }
        xAxis.setLabels(Util.mapCollectionToObjectArray(labels));
        chart.setOrientation(Orientation.HORIZONTAL_LEGEND_CHART);
        ret = chart.getHtmlSnipplet();
        cache(ret);
    }
    return ret;
}

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  . ja v a  2s. 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.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   w  ww  .j  av a2 s.co m
    }
    return null;
}

From source file:org.estatio.dom.index.IndexBase.java

License:Apache License

@Programmatic
public BigDecimal factorForDate(final LocalDate date) {
    return date.isBefore(getStartDate()) ? getFactor().multiply(getPrevious().factorForDate(date))
            : BigDecimal.ONE;// w w  w  .j  ava  2s  .  co m
}

From source file:org.estatio.dom.lease.Lease.java

License:Apache License

public String validateTerminate(final LocalDate terminationDate, final Boolean confirm) {
    if (terminationDate.isBefore(getStartDate())) {
        return "Termination date can't be before start date";
    }//from   w ww  .  j a v a2  s  .  co m
    return confirm ? null : "Make sure you confirm this action";
}

From source file:org.estatio.dom.lease.Lease.java

License:Apache License

public String validateRenew(final String reference, final String name, final LocalDate startDate,
        final LocalDate endDate, final Boolean confirm) {
    if (endDate.isBefore(startDate)) {
        return "End date can not be before start date.";
    }// www  . j a  v a  2s.  co  m
    return leases.findLeaseByReferenceElseNull(reference) == null ? null : "Lease reference already exists.";
}