Example usage for org.joda.time DateTime minusDays

List of usage examples for org.joda.time DateTime minusDays

Introduction

In this page you can find the example usage for org.joda.time DateTime minusDays.

Prototype

public DateTime minusDays(int days) 

Source Link

Document

Returns a copy of this datetime minus the specified number of days.

Usage

From source file:rapture.dp.invocable.CheckPrerequisiteStep.java

License:Open Source License

private boolean isDataReady(CallingContext ctx, PrerequisiteConfig config) {
    outer: for (PrerequisiteConfig.RequiredData requiredData : config.getRequiredData()) {
        if (log.isDebugEnabled())
            log.debug("Check requirement " + requiredData.toString());
        String uri = requiredData.getUri();
        int chevron = uri.indexOf('<');
        RaptureURI ruri = new RaptureURI((chevron > 0) ? uri.substring(0, chevron - 1) : uri);
        String keyFormat = requiredData.getKeyFormat();
        if (StringUtils.isEmpty(keyFormat))
            keyFormat = "yyyyMMdd";
        String specificDate = StringUtils.trimToNull(requiredData.getSpecificDate());
        if ((specificDate != null) && specificDate.startsWith("$")) {
            specificDate = Kernel.getDecision().getContextValue(ctx, getWorkerURI(), specificDate.substring(1));
        }/*from  ww  w .  jav  a  2 s .  com*/

        // For series we look for a data point with the valid date
        if (ruri.getScheme().equals(Scheme.SERIES)) {
            if (specificDate != null)
                log.warn("specificDate not supported for series data");
            DateTime acceptableTime = getDateTime(DateTime.now().withTimeAtStartOfDay(),
                    requiredData.getDateWithin(), requiredData.getTimeNoEarlierThan());

            if (!isDataReady.contains(uri)) {
                if (!Kernel.getSeries().seriesExists(ctx, uri)) {
                    log.debug("Series not found " + uri);
                    return false;
                }
                SeriesPoint lastDataPoint = Kernel.getSeries().getLastPoint(ctx, uri);
                DateTime lastDataPointTime = DateTime.parse(lastDataPoint.getColumn(),
                        DateTimeFormat.forPattern(keyFormat));
                log.debug("Last data point is at " + lastDataPointTime);
                if (lastDataPointTime.isBefore(acceptableTime)) {
                    log.debug("data point is outside acceptable range");
                    return false;
                } else {
                    log.debug("data point is valid");
                    isDataReady.add(uri);
                }
            } else {
                log.debug("data point already seen");
            }
        } else {
            // For types other than series we simply check for the existence of the blob/doc/sheet etc.

            DateTime start = (specificDate != null)
                    ? DateTime.parse(specificDate, DateTimeFormat.forPattern(keyFormat))
                    : DateTime.now().withTimeAtStartOfDay();
            DateTime acceptableTime = getDateTime(start, requiredData.getDateWithin(),
                    requiredData.getTimeNoEarlierThan());

            DateTime lastDataPointTime = (specificDate == null) ? new DateTime() : acceptableTime;
            SimpleDateFormat sdf = new SimpleDateFormat(keyFormat);

            while (!lastDataPointTime.isBefore(acceptableTime)) {
                String datedUri = uri;
                if (uri.contains("<DATE>"))
                    datedUri = uri.replace("<DATE>", sdf.format(lastDataPointTime.toDate()));
                if (isDataReady.contains(datedUri)) {
                    if (log.isDebugEnabled())
                        log.debug(datedUri.toString() + " already seen");
                    continue outer;
                }

                boolean uriExists = false;
                // There is no generic exists method.
                switch (ruri.getScheme()) {
                case BLOB:
                    uriExists = Kernel.getBlob().blobExists(ctx, datedUri);
                    break;
                case DOCUMENT:
                    uriExists = Kernel.getDoc().docExists(ctx, datedUri);
                    break;
                default:
                    log.warn("Unexpected URI type : " + uri);
                    return false;
                }
                if (uriExists) {
                    if (log.isDebugEnabled())
                        log.debug(datedUri.toString() + " found");
                    isDataReady.add(uri);
                    continue outer;
                }
                // Go back one day
                lastDataPointTime = lastDataPointTime.minusDays(1);
            }

            // Fail because we went outside acceptable time range
            // - we continue the outer for loop if successful
            log.debug("requirement not met");
            return false;
        }
    }
    // All found
    return true;
}

From source file:rapture.dp.invocable.CheckPrerequisiteStep.java

License:Open Source License

private DateTime getDateTime(DateTime dateTime, String dateWithin, String timeNoEarlierThan) {
    if (!StringUtils.isEmpty(timeNoEarlierThan)) {
        DateTime hours = getDateTime(timeNoEarlierThan);
        if (dateTime == null)
            dateTime = hours;//from  w  w w.j  a v a 2 s . c o m
        else {
            dateTime = dateTime.withMillisOfDay(hours.getMillisOfDay()).withZone(hours.getZone());
        }
    }
    if (!StringUtils.isEmpty(dateWithin)) {
        int number = Integer.valueOf(dateWithin.substring(0, dateWithin.length() - 1));
        char dateUnit = dateWithin.charAt(dateWithin.length() - 1);
        switch (dateUnit) {
        case 'M':
            dateTime = dateTime.minusMonths(number);
            break;
        case 'W':
            dateTime = dateTime.minusWeeks(number);
            break;
        case 'D':
            dateTime = dateTime.minusDays(number);
            break;
        case 'H':
            dateTime = dateTime.minusHours(number);
            break;
        case 'B':
            dateTime = USCalendar.minusBusinessDays(dateTime, number);
            break;
        default:
            throw RaptureExceptionFactory.create("Invalid date unit " + dateUnit);
        }
    }
    return dateTime;
}

From source file:syncthing.android.service.SyncthingUtils.java

License:Open Source License

public static Interval getIntervalForRange(DateTime now, long start, long end) {
    DateTime daybreak = now.withTimeAtStartOfDay();
    Interval interval;//from   www.j a v  a2  s  .com
    if (start < end) {
        //same day
        interval = new Interval(daybreak.plus(start), daybreak.plus(end));
    } else /*start >|== end*/ {
        if (now.isAfter(daybreak.plus(start))) {
            //rolls next day
            interval = new Interval(daybreak.plus(start), daybreak.plusDays(1).plus(end));
        } else {
            //rolls previous day
            interval = new Interval(daybreak.minusDays(1).plus(start), daybreak.plus(end));
        }
    }
    return interval;
}

From source file:trendulo.web.date.DateConverter.java

License:Apache License

/**
 * Get the date string for the start of time period days days ago from timestamp
 * @param days the number of days in the past from timestamp
 * @param timestamp the time reference//from w  w  w . j av a2 s .co m
 * @return a dateString in the form of yyyyMMdd or yyyyMMddHH
 */
public static String getStartDateString(int days, long timestamp) {
    DateTimeFormatter formatter = getFormatterForDays(days);

    // Do the date arithmetic ( timestamp - days )
    //DateTime dateTime = new DateTime( timestamp, DateTimeZone.UTC );
    DateTime dateTime = new DateTime(timestamp, mdtDateTimeZone);
    DateTime startDateTime = dateTime.minusDays(days);

    //return formatter.withZoneUTC().print( startDateTime );
    return formatter.withZone(mdtDateTimeZone).print(startDateTime);
}

From source file:TVShowTimelineMaker.testUtil.DateTimeMaker.java

public static DateTime randomDateTimeBeforeTimeSure(DateTime inDay) {
    return randomDateTimeBetweenTimes(startTime.minusDays(1), inDay.minusDays(1));
}

From source file:TVShowTimelineMaker.testUtil.RandomEvents.java

public static OncePeriodEvent randomOverlapsEvent(OncePeriodEvent inOncePeriodEvent) {
    DateTime EarliestStartTime;/* w w  w .ja va 2 s. co  m*/
    DateTime LatestEndTime;
    DateTime middle1;
    DateTime middle2;
    if (rnd.nextBoolean()) {
        DateTime interTime = inOncePeriodEvent.getEarliestPossibleEndTime();
        if (interTime.isAfter(inOncePeriodEvent.getLatestPossibleStartTime())) {
            interTime = inOncePeriodEvent.getLatestPossibleStartTime();
        }
        LatestEndTime = DateTimeMaker.randomDateTimeBetweenTimes(interTime.plusDays(1),
                inOncePeriodEvent.getLatestPossibleEndTime().plusDays(1));
        EarliestStartTime = DateTimeMaker
                .randomDateTimeBeforeTime(inOncePeriodEvent.getEarliestPossibleStartTime().minusDays(1));
        middle1 = DateTimeMaker.randomDateTimeBetweenTimes(EarliestStartTime, LatestEndTime);
        middle2 = DateTimeMaker.randomDateTimeBetweenTimes(interTime, LatestEndTime);
    } else {
        DateTime interTime = inOncePeriodEvent.getLatestPossibleStartTime();
        if (interTime.isBefore(inOncePeriodEvent.getEarliestPossibleEndTime())) {
            interTime = inOncePeriodEvent.getEarliestPossibleEndTime();
        }
        EarliestStartTime = DateTimeMaker.randomDateTimeBetweenTimes(
                inOncePeriodEvent.getEarliestPossibleStartTime().minusDays(1), interTime.minusDays(1));
        LatestEndTime = DateTimeMaker
                .randomDateTimeAfterTime(inOncePeriodEvent.getLatestPossibleEndTime().plusDays(1));
        middle1 = DateTimeMaker.randomDateTimeBetweenTimes(EarliestStartTime, interTime);
        middle2 = DateTimeMaker.randomDateTimeBetweenTimes(EarliestStartTime, LatestEndTime);
    }
    OncePeriodEvent newOncePeriodEvent = new OncePeriodEvent();
    newOncePeriodEvent.setEarliestPossibleDateForStart(EarliestStartTime);
    newOncePeriodEvent.setLatestPossibleDateForStart(middle1);
    newOncePeriodEvent.setEarliestPossibleDateForEnd(middle2);
    newOncePeriodEvent.setLatestPossibleDateForEnd(LatestEndTime);
    int maxDuration = 1 + rnd.nextInt(java.lang.Integer.MAX_VALUE);
    newOncePeriodEvent.setMaxDuration(maxDuration);
    newOncePeriodEvent.normalize();
    if (newOncePeriodEvent.getMaxDuration() >= 1) {
        newOncePeriodEvent.setMinDuration(rnd.nextInt(newOncePeriodEvent.getMaxDuration()));
        newOncePeriodEvent.normalize();
    }
    return newOncePeriodEvent;
}

From source file:TVShowTimelineMaker.timeConstraints.AbutsContraint.java

@Override
public boolean complexApplyConstraint() {
    boolean changed = this.applyConstraint();
    if (this.mFirstPeriodEvent instanceof OncePeriodEvent) {
        OncePeriodEvent mFirstOncePeriodEvent = (OncePeriodEvent) this.mFirstPeriodEvent;
        if (this.mSecondPeriodEvent instanceof OncePeriodEvent) {
            OncePeriodEvent mSecondOncePeriodEvent = (OncePeriodEvent) this.mSecondPeriodEvent;
            Set<DateTime> startDays1 = new java.util.HashSet<>(mFirstOncePeriodEvent.getEndPossibleDays());
            for (DateTime curDay : mFirstOncePeriodEvent.getEndPossibleDays()) {
                startDays1.add(curDay.plusDays(1));
            }/*from   w  w  w . j  a  v  a2s .  c om*/
            Set<DateTime> endDays1 = new java.util.HashSet<>(
                    mSecondOncePeriodEvent.getStartPossibleDays().size());
            for (DateTime curDay : mSecondOncePeriodEvent.getStartPossibleDays()) {
                endDays1.add(curDay.minusDays(1));
            }
            if (!endDays1.containsAll(mFirstOncePeriodEvent.getEndPossibleDays())) {
                mFirstOncePeriodEvent.getEndPossibleDays().retainAll(endDays1);
                changed = true;
            }
            if (!startDays1.containsAll(mSecondOncePeriodEvent.getStartPossibleDays())) {
                mSecondOncePeriodEvent.getStartPossibleDays().retainAll(startDays1);
                changed = true;
            }
        } else if (this.mSecondPeriodEvent instanceof YearlyPeriodEvent) {
            YearlyPeriodEvent mSecondSeason = (YearlyPeriodEvent) this.mSecondPeriodEvent;
            Set<DayOfYear> secondDays = new java.util.HashSet<>(31);
            DateTime endDay = mFirstOncePeriodEvent.getLatestPossibleEndTime().withHourOfDay(23);
            for (DateTime curDay = mFirstOncePeriodEvent.getEarliestPossibleEndTime().withHourOfDay(1); curDay
                    .isBefore(endDay); curDay = curDay.plusDays(1)) {
                secondDays.add(DayOfYear.fromDateTime(curDay.plusDays(1)));
            }
            if (!secondDays.containsAll(mSecondSeason.getStartPossibleDays())) {
                mSecondSeason.getStartPossibleDays().retainAll(secondDays);
                changed = true;
            }

            Set<DayOfYear> beforeSecondEvent = new java.util.HashSet<>(31);
            for (DayOfYear curDay : mSecondSeason.getStartPossibleDays()) {
                beforeSecondEvent.add(curDay.plusDays(-1));
            }
            Iterator<DateTime> firstEndTimesIterator = mFirstOncePeriodEvent.getEndPossibleDays().iterator();
            while (firstEndTimesIterator.hasNext()) {
                DateTime curDateTime = firstEndTimesIterator.next();
                DayOfYear curDayOfYear = DayOfYear.fromDateTime(curDateTime);
                if (!beforeSecondEvent.contains(curDayOfYear)) {
                    firstEndTimesIterator.remove();
                }
            }
        }
    } else if (this.mFirstPeriodEvent instanceof YearlyPeriodEvent) {
        YearlyPeriodEvent mFirstSeason = (YearlyPeriodEvent) this.mFirstPeriodEvent;
        Set<DayOfYear> startDays1 = new java.util.HashSet<>(mFirstSeason.getEndPossibleDays().size());
        for (DayOfYear curDay : mFirstSeason.getEndPossibleDays()) {
            startDays1.add(curDay.plusDays(1));
        }
        if (this.mSecondPeriodEvent instanceof OncePeriodEvent) {
            OncePeriodEvent mSecondOncePeriodEvent = (OncePeriodEvent) this.mSecondPeriodEvent;
            Set<DayOfYear> days = new java.util.HashSet<>(31);
            DateTime endDay = mSecondOncePeriodEvent.getLatestPossibleStartTime().withHourOfDay(23);
            for (DateTime curDay = mSecondOncePeriodEvent.getEarliestPossibleStartTime()
                    .withHourOfDay(1); curDay.isBefore(endDay); curDay = curDay.plusDays(1)) {
                days.add(DayOfYear.fromDateTime(curDay.minusDays(1)));
            }
            if (!days.containsAll(mFirstSeason.getEndPossibleDays())) {
                mFirstSeason.getEndPossibleDays().retainAll(days);
                changed = true;
            }

            Set<DayOfYear> afterFirstEvent = new java.util.HashSet<>(31);
            for (DayOfYear curDay : mFirstSeason.getEndPossibleDays()) {
                afterFirstEvent.add(curDay.plusDays(1));
            }
            Iterator<DateTime> secondStartTimesIterator = mSecondOncePeriodEvent.getStartPossibleDays()
                    .iterator();
            while (secondStartTimesIterator.hasNext()) {
                DateTime curDateTime = secondStartTimesIterator.next();
                DayOfYear curDayOfYear = DayOfYear.fromDateTime(curDateTime);
                if (!afterFirstEvent.contains(curDayOfYear)) {
                    secondStartTimesIterator.remove();
                }
            }
        } else if (this.mSecondPeriodEvent instanceof YearlyPeriodEvent) {
            YearlyPeriodEvent mSecondSeason = (YearlyPeriodEvent) this.mSecondPeriodEvent;
            Set<DayOfYear> endDays1 = new java.util.HashSet<>(mSecondSeason.getStartPossibleDays().size());
            for (DayOfYear curDay : mSecondSeason.getStartPossibleDays()) {
                endDays1.add(curDay.plusDays(-1));
            }
            if (!endDays1.containsAll(mFirstSeason.getEndPossibleDays())) {
                mFirstSeason.getEndPossibleDays().retainAll(endDays1);
                changed = true;
            }
            if (!startDays1.containsAll(mSecondSeason.getStartPossibleDays())) {
                mSecondSeason.getStartPossibleDays().retainAll(startDays1);
                changed = true;
            }
        }
    }
    return changed;
}

From source file:TVShowTimelineMaker.timeline.OnceDayEvent.java

/**
 * like String.trim() but removes impossible days from the beginning and end
 * of the interval specified by earliestPossibleDate to latestPossibleDate
 *///from   ww w  .java2  s . c  om
@Override
public void normalize() {
    DateTime endDate = this.latestPossibleDate.withHourOfDay(23);

    DateTime iTime = this.earliestPossibleDate.withHourOfDay(11);
    while ((!this.mDayAcceptor.accept(iTime)) && (iTime.isBefore(endDate))) {
        iTime = iTime.plusDays(1);
    }
    this.earliestPossibleDate = iTime;
    DateTime startDate = this.earliestPossibleDate.withHourOfDay(1);
    iTime = this.latestPossibleDate.withHourOfDay(13);
    while ((!this.mDayAcceptor.accept(iTime)) && (iTime.isAfter(startDate))) {
        iTime = iTime.minusDays(1);
    }
    this.latestPossibleDate = iTime;

    if (!this.PossibleDays.isEmpty()) {
        this.trimPossibleDays();
    }
    this.lastmodifyed = System.currentTimeMillis();
}

From source file:TVShowTimelineMaker.timeline.OncePeriodEvent.java

@Override
public void normalize() {
    if (this.isValid()) {
        if (this.earliestPossibleDateForStart.isBefore(this.earliestPossibleDateForEnd)) {
            int diffStarts = new Interval(this.earliestPossibleDateForStart, this.earliestPossibleDateForEnd)
                    .toPeriod(org.joda.time.PeriodType.days()).getDays();
            if (diffStarts < this.getMinDuration()) {
                this.setEarliestPossibleDateForEnd(
                        this.earliestPossibleDateForStart.plusDays(this.getMinDuration()));
            } else if (diffStarts > this.getMaxDuration()) {
                int addjust = diffStarts - this.getMaxDuration();
                this.setEarliestPossibleDateForStart(this.earliestPossibleDateForStart.plusDays(addjust));
            }/*w ww .j  a v  a2 s . c o  m*/
            if (!this.earliestPossibleDateForStart.isBefore(this.latestPossibleDateForStart)) {
                int a = 1 + 3;
            }
        }
        if (this.latestPossibleDateForStart.isBefore(this.latestPossibleDateForEnd)) {
            int diffEnds = new Interval(this.latestPossibleDateForStart, this.latestPossibleDateForEnd)
                    .toPeriod(org.joda.time.PeriodType.days()).getDays();
            if (diffEnds < this.getMinDuration()) {
                this.setLatestPossibleDateForStart(
                        this.latestPossibleDateForEnd.minusDays(this.getMinDuration()));
            } else if (diffEnds > this.getMaxDuration()) {
                int addjust = diffEnds - this.getMaxDuration();
                this.setLatestPossibleDateForEnd(this.latestPossibleDateForEnd.minusDays(addjust));
            }
            if (!this.earliestPossibleDateForStart.isBefore(this.latestPossibleDateForEnd)) {
                int a = 1 + 1;
            }
        }
        if (this.latestPossibleDateForStart.isBefore(this.earliestPossibleDateForEnd)) {
            long shortestTimeLong = new Interval(this.latestPossibleDateForStart,
                    this.earliestPossibleDateForEnd).toDuration().getStandardDays();
            int shortestTime = (int) Math.min(shortestTimeLong, java.lang.Integer.MAX_VALUE);
            if (shortestTime > this.minDuration) {
                this.setMinDuration(shortestTime);
            }
        }
        //todo: remove. debug
        if (!this.earliestPossibleDateForStart.isBefore(this.latestPossibleDateForEnd)) {
            int a = 1 + 1;
        }
        //end debug
        int longestTime = new Interval(this.earliestPossibleDateForStart.withHourOfDay(1),
                this.latestPossibleDateForEnd.withHourOfDay(23)).toPeriod(org.joda.time.PeriodType.days())
                        .getDays();
        if (longestTime < this.maxDuration) {
            this.setMaxDuration(longestTime);
        }
        if (this.isMarkedForComplexEval()) {
            if (this.startPossibleDays.first().isAfter(this.earliestPossibleDateForStart)) {
                this.setEarliestPossibleDateForStart(this.startPossibleDays.first());
            }
            if (this.startPossibleDays.last().isBefore(this.latestPossibleDateForStart)) {
                this.setLatestPossibleDateForStart(this.startPossibleDays.last());
            }
            if (this.endPossibleDays.first().isAfter(this.earliestPossibleDateForEnd)) {
                this.setEarliestPossibleDateForEnd(this.endPossibleDays.first());
            }
            if (this.endPossibleDays.last().isBefore(this.latestPossibleDateForEnd)) {
                this.setLatestPossibleDateForEnd(this.endPossibleDays.last());
            }
            while (this.startPossibleDays.first().isBefore(this.earliestPossibleDateForStart)) {
                this.startPossibleDays.pollFirst();
            }
            while (this.startPossibleDays.last().isAfter(this.earliestPossibleDateForStart)) {
                this.startPossibleDays.pollLast();
            }
            while (this.endPossibleDays.first().isBefore(this.earliestPossibleDateForEnd)) {
                this.endPossibleDays.pollFirst();
            }
            while (this.endPossibleDays.last().isAfter(this.earliestPossibleDateForEnd)) {
                this.endPossibleDays.pollLast();
            }
            Iterator<OncePeriodEventPlacement> PlacementIterator = this.mVaildPlacements.iterator();
            Collection<DateTime> retainStartDays = new java.util.HashSet<>(1);
            Collection<DateTime> retainEndDays = new java.util.HashSet<>(1);
            while (PlacementIterator.hasNext()) {
                OncePeriodEventPlacement curPlacement = PlacementIterator.next();
                if ((!this.startPossibleDays.contains(curPlacement.startDay))
                        || (!this.endPossibleDays.contains(curPlacement.endDay))) {
                    PlacementIterator.remove();
                } else {
                    long curSeasonPlacementDuration = curPlacement.getDurationDays();
                    if ((curSeasonPlacementDuration < this.minDuration)
                            || (curSeasonPlacementDuration > this.maxDuration)) {
                        PlacementIterator.remove();
                    } else {
                        retainStartDays.add(curPlacement.startDay);
                        retainEndDays.add(curPlacement.endDay);
                    }
                }
            }
            this.startPossibleDays.retainAll(retainStartDays);
            this.endPossibleDays.retainAll(retainEndDays);
        } else {
            DateTime endDate = this.latestPossibleDateForStart.withHourOfDay(23);

            DateTime iTime = this.earliestPossibleDateForStart.withHourOfDay(11);
            while ((!this.startAndDayAcceptor.accept(iTime)) && (iTime.isBefore(endDate))) {
                iTime = iTime.plusDays(1);
            }
            this.setEarliestPossibleDateForStart(iTime);

            DateTime startDate = this.earliestPossibleDateForStart.withHourOfDay(1);
            iTime = this.latestPossibleDateForStart.withHourOfDay(13);
            while ((!this.startAndDayAcceptor.accept(iTime)) && (iTime.isAfter(startDate))) {
                iTime = iTime.minusDays(1);
            }
            this.setLatestPossibleDateForStart(iTime);
            endDate = this.latestPossibleDateForEnd.withHourOfDay(23);

            iTime = this.earliestPossibleDateForEnd.withHourOfDay(11);
            while ((!this.endAndDayAcceptor.accept(iTime)) && (iTime.isBefore(endDate))) {
                iTime = iTime.plusDays(1);
            }
            this.setEarliestPossibleDateForEnd(iTime);

            startDate = this.earliestPossibleDateForEnd.withHourOfDay(1);
            iTime = this.latestPossibleDateForEnd.withHourOfDay(13);
            while ((!this.endAndDayAcceptor.accept(iTime)) && (iTime.isAfter(startDate))) {
                iTime = iTime.minusDays(1);
            }
            this.setLatestPossibleDateForEnd(iTime);
        }
    }
}

From source file:ua.web.AccountingUtility.java

private boolean checkDateFilter(HttpServletRequest request, String dateOfAction) {
    String fromDate = request.getParameter("fromDate");
    String toDate = request.getParameter("toDate");
    String oneDate = request.getParameter("oneDate");
    String dateFilter = request.getParameter("dateFilter");
    request.setAttribute("selectedDateFilter", dateFilter);
    DateTime aDate = format.parseDateTime(dateOfAction);
    if (paramExist(fromDate) && paramExist(toDate)) {
        DateTime fDate = customFormat.parseDateTime(fromDate);
        DateTime tDate = customFormat.parseDateTime(toDate);
        return aDate.isBefore(tDate) && aDate.isAfter(fDate);
    } else if (paramExist(oneDate)) {
        DateTime oDate = customFormat.parseDateTime(oneDate);
        DateTime temp = oDate.plusDays(1);
        return aDate.isAfter(oDate) && aDate.isBefore(temp);
    } else if (paramExist(dateFilter)) {
        DateTime now = new DateTime();
        DateTime temp;// w w w  . ja v a2 s  .co  m
        if (dateFilter.equals("This 24 hours")) {
            temp = now.minusDays(1);
        } else if (dateFilter.equals("This week")) {
            temp = now.minusDays(7);
        } else if (dateFilter.equals("This month")) {
            temp = now.minusDays(30);
        } else {
            return true;
        }
        return aDate.isAfter(temp) && aDate.isBefore(now);
    }
    return false;
}