org.joda.time.MutableDateTime#addDays ( )源码实例Demo

下面列出了org.joda.time.MutableDateTime#addDays ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: rice   文件: DocumentSearchServiceImpl.java
protected DocumentSearchCriteria applyCriteriaDefaults(DocumentSearchCriteria criteria) {
    DocumentSearchCriteria.Builder comparisonCriteria = createEmptyComparisonCriteria(criteria);
    boolean isCriteriaEmpty = criteria.equals(comparisonCriteria.build());
    boolean isTitleOnly = false;
    boolean isDocTypeOnly = false;
    if (!isCriteriaEmpty) {
        comparisonCriteria.setTitle(criteria.getTitle());
        isTitleOnly = criteria.equals(comparisonCriteria.build());
    }

    if (!isCriteriaEmpty && !isTitleOnly) {
        comparisonCriteria = createEmptyComparisonCriteria(criteria);
        comparisonCriteria.setDocumentTypeName(criteria.getDocumentTypeName());
        isDocTypeOnly = criteria.equals(comparisonCriteria.build());
    }

    if (isCriteriaEmpty || isTitleOnly || isDocTypeOnly) {
        DocumentSearchCriteria.Builder criteriaBuilder = DocumentSearchCriteria.Builder.create(criteria);
        Integer defaultCreateDateDaysAgoValue = null;
        if (isCriteriaEmpty || isDocTypeOnly) {
            // if they haven't set any criteria, default the from created date to today minus days from constant variable
            defaultCreateDateDaysAgoValue = KewApiConstants.DOCUMENT_SEARCH_NO_CRITERIA_CREATE_DATE_DAYS_AGO;
        } else if (isTitleOnly) {
            // If the document title is the only field which was entered, we want to set the "from" date to be X
            // days ago.  This will allow for a more efficient query.
            defaultCreateDateDaysAgoValue = KewApiConstants.DOCUMENT_SEARCH_DOC_TITLE_CREATE_DATE_DAYS_AGO;
        }

        if (defaultCreateDateDaysAgoValue != null) {
            // add a default create date
            MutableDateTime mutableDateTime = new MutableDateTime();
            mutableDateTime.addDays(defaultCreateDateDaysAgoValue.intValue());
            criteriaBuilder.setDateCreatedFrom(mutableDateTime.toDateTime());
        }
        criteria = criteriaBuilder.build();
    }
    return criteria;
}
 
源代码2 项目: BaldPhone   文件: AlarmScheduler.java
static long nextTimeAlarmWillWorkInMs(@NonNull Alarm alarm) {
    final MutableDateTime mDateTime = MutableDateTime.now();
    {   //creating a date of today with the hours and minutes of the alarm
        mDateTime.setMillisOfSecond(0);
        mDateTime.setSecondOfMinute(0);
        mDateTime.setHourOfDay(alarm.getHour());
        mDateTime.setMinuteOfHour(alarm.getMinute());
    }

    final int baldDay = getBaldDay();

    {   //today or one time
        if ((alarm.getDays() & baldDay) == baldDay) {//today may have an alarm
            if ((alarm.getDays() == baldDay)) {
                if (mDateTime.isBeforeNow())
                    mDateTime.addWeeks(1);  //next week if today's time already passed
                return mDateTime.getMillis();
            } else {
                if (mDateTime.isAfterNow())
                    return mDateTime.getMillis();
            }
        } else if (alarm.getDays() == -1) {
            if (mDateTime.isBeforeNow())
                mDateTime.addDays(1);
            return mDateTime.getMillis();
        }
    }
    int selectedBaldDay = baldDay;

    {   //find next day
        for (int i = baldDay << 1; i != baldDay; i <<= 1) {
            if (i > D.Days.SATURDAY)
                i = D.Days.SUNDAY;

            if ((alarm.getDays() & i) == i) {
                selectedBaldDay = i;
                break;
            }

        }
    }

    int day = baldDayToJodaDay(selectedBaldDay);
    mDateTime.setDayOfWeek(day);
    if (mDateTime.isBeforeNow()) {
        mDateTime.addWeeks(1);
    }
    return mDateTime.getMillis();
}
 
源代码3 项目: BaldPhone   文件: ReminderScheduler.java
private static long nextTimeReminderWillWorkInMs(@NonNull Reminder reminder, Context context) {
    final MutableDateTime mDateTime = MutableDateTime.now();

    {   //creating a date of today with the hours and minutes of the alarm
        mDateTime.setMillisOfSecond(0);
        mDateTime.setSecondOfMinute(0);

        mDateTime.setHourOfDay(BPrefs.getHour(reminder.getStartingTime(), context));
        mDateTime.setMinuteOfHour(BPrefs.getMinute(reminder.getStartingTime(), context));
    }

    final int baldDay = getBaldDay();
    final int days = reminder.getDays();
    {   //today or one time
        if ((days & baldDay) == baldDay) {//today may have an alarm
            if ((days == baldDay)) {
                if (mDateTime.isBeforeNow())
                    mDateTime.addWeeks(1);  //next week if today's time already passed
                return mDateTime.getMillis();
            } else {
                if (mDateTime.isAfterNow())
                    return mDateTime.getMillis();
            }
        } else if (days == -1) {
            if (mDateTime.isBeforeNow())
                mDateTime.addDays(1);
            return mDateTime.getMillis();
        }
    }

    int selectedBaldDay = baldDay;

    {   //find next day
        for (int i = baldDay << 1; i != baldDay; i <<= 1) {
            if (i > D.Days.SATURDAY)
                i = D.Days.SUNDAY;

            if ((days & i) == i) {
                selectedBaldDay = i;
                break;
            }

        }
    }

    int day = baldDayToJodaDay(selectedBaldDay);
    mDateTime.setDayOfWeek(day);
    if (mDateTime.isBeforeNow()) {
        mDateTime.addWeeks(1);
    }
    return mDateTime.getMillis();
}
 
源代码4 项目: chronos   文件: CronExpression.java
@CoverageIgnore
public DateTime nextTimeAfter(DateTime afterTime, DateTime dateTimeBarrier) {
    MutableDateTime nextTime = new MutableDateTime(afterTime);
    nextTime.setMillisOfSecond(0);
    nextTime.secondOfDay().add(1);

    while (true) { // day of week
        while (true) { // month
            while (true) { // day of month
                while (true) { // hour
                    while (true) { // minute
                        while (true) { // second
                            if (secondField.matches(nextTime.getSecondOfMinute())) {
                                break;
                            }
                            nextTime.secondOfDay().add(1);
                        }
                        if (minuteField.matches(nextTime.getMinuteOfHour())) {
                            break;
                        }
                        nextTime.minuteOfDay().add(1);
                        nextTime.secondOfMinute().set(0);
                    }
                    if (hourField.matches(nextTime.getHourOfDay())) {
                        break;
                    }
                    nextTime.hourOfDay().add(1);
                    nextTime.minuteOfHour().set(0);
                    nextTime.secondOfMinute().set(0);
                }
                if (dayOfMonthField.matches(new LocalDate(nextTime))) {
                    break;
                }
                nextTime.addDays(1);
                nextTime.setTime(0, 0, 0, 0);
                checkIfDateTimeBarrierIsReached(nextTime, dateTimeBarrier);
            }
            if (monthField.matches(nextTime.getMonthOfYear())) {
                break;
            }
            nextTime.addMonths(1);
            nextTime.setDayOfMonth(1);
            nextTime.setTime(0, 0, 0, 0);
            checkIfDateTimeBarrierIsReached(nextTime, dateTimeBarrier);
        }
        if (dayOfWeekField.matches(new LocalDate(nextTime))) {
            break;
        }
        nextTime.addDays(1);
        nextTime.setTime(0, 0, 0, 0);
        checkIfDateTimeBarrierIsReached(nextTime, dateTimeBarrier);
    }

    return nextTime.toDateTime();
}
 
源代码5 项目: cron   文件: CronExpression.java
public DateTime nextTimeAfter(DateTime afterTime, DateTime dateTimeBarrier) {
    MutableDateTime nextTime = new MutableDateTime(afterTime);
    nextTime.setMillisOfSecond(0);
    nextTime.secondOfDay().add(1);

    while (true) { // day of week
        while (true) { // month
            while (true) { // day of month
                while (true) { // hour
                    while (true) { // minute
                        while (true) { // second
                            if (secondField.matches(nextTime.getSecondOfMinute())) {
                                break;
                            }
                            nextTime.secondOfDay().add(1);
                        }
                        if (minuteField.matches(nextTime.getMinuteOfHour())) {
                            break;
                        }
                        nextTime.minuteOfDay().add(1);
                        nextTime.secondOfMinute().set(0);
                    }
                    if (hourField.matches(nextTime.getHourOfDay())) {
                        break;
                    }
                    nextTime.hourOfDay().add(1);
                    nextTime.minuteOfHour().set(0);
                    nextTime.secondOfMinute().set(0);
                }
                if (dayOfMonthField.matches(new LocalDate(nextTime))) {
                    break;
                }
                nextTime.addDays(1);
                nextTime.setTime(0, 0, 0, 0);
                checkIfDateTimeBarrierIsReached(nextTime, dateTimeBarrier);
            }
            if (monthField.matches(nextTime.getMonthOfYear())) {
                break;
            }
            nextTime.addMonths(1);
            nextTime.setDayOfMonth(1);
            nextTime.setTime(0, 0, 0, 0);
            checkIfDateTimeBarrierIsReached(nextTime, dateTimeBarrier);
        }
        if (dayOfWeekField.matches(new LocalDate(nextTime))) {
            break;
        }
        nextTime.addDays(1);
        nextTime.setTime(0, 0, 0, 0);
        checkIfDateTimeBarrierIsReached(nextTime, dateTimeBarrier);
    }

    return nextTime.toDateTime();
}
 
源代码6 项目: actframework   文件: CronExpression.java
public DateTime nextTimeAfter(DateTime afterTime, DateTime dateTimeBarrier) {
    MutableDateTime nextTime = new MutableDateTime(afterTime);
    nextTime.setMillisOfSecond(0);
    nextTime.secondOfDay().add(1);

    while (true) { // day of week
        while (true) { // month
            while (true) { // day of month
                while (true) { // hour
                    while (true) { // minute
                        while (true) { // second
                            if (secondField.matches(nextTime.getSecondOfMinute())) {
                                break;
                            }
                            nextTime.secondOfDay().add(1);
                        }
                        if (minuteField.matches(nextTime.getMinuteOfHour())) {
                            break;
                        }
                        nextTime.minuteOfDay().add(1);
                        nextTime.secondOfMinute().set(0);
                    }
                    if (hourField.matches(nextTime.getHourOfDay())) {
                        break;
                    }
                    nextTime.hourOfDay().add(1);
                    nextTime.minuteOfHour().set(0);
                    nextTime.secondOfMinute().set(0);
                }
                if (dayOfMonthField.matches(new LocalDate(nextTime))) {
                    break;
                }
                nextTime.addDays(1);
                nextTime.setTime(0, 0, 0, 0);
                checkIfDateTimeBarrierIsReached(nextTime, dateTimeBarrier);
            }
            if (monthField.matches(nextTime.getMonthOfYear())) {
                break;
            }
            nextTime.addMonths(1);
            nextTime.setDayOfMonth(1);
            nextTime.setTime(0, 0, 0, 0);
            checkIfDateTimeBarrierIsReached(nextTime, dateTimeBarrier);
        }
        if (dayOfWeekField.matches(new LocalDate(nextTime))) {
            break;
        }
        nextTime.addDays(1);
        nextTime.setTime(0, 0, 0, 0);
        checkIfDateTimeBarrierIsReached(nextTime, dateTimeBarrier);
    }

    return nextTime.toDateTime();
}