当前位置: 首页>>代码示例>>Java>>正文


Java DateMidnight.plusDays方法代码示例

本文整理汇总了Java中org.joda.time.DateMidnight.plusDays方法的典型用法代码示例。如果您正苦于以下问题:Java DateMidnight.plusDays方法的具体用法?Java DateMidnight.plusDays怎么用?Java DateMidnight.plusDays使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.joda.time.DateMidnight的用法示例。


在下文中一共展示了DateMidnight.plusDays方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: AbstractWeek

import org.joda.time.DateMidnight; //导入方法依赖的package包/类
public AbstractWeek(DateMidnight weekStart, DateMidnight weekEnd) {
    this.weekStart = weekStart;
    this.weekEnd = weekEnd;
    weekInterval = new Interval(weekStart, weekEnd);
    AbstractMonthView.logger.debug("Week interval: {}", weekInterval);

    AbstractMonthView.logger.debug("Initializing days");
    days = createDaysArray(7);
    DateMidnight dayStart = weekStart;
    for (int i = 0; i < 7; i++) {
        DateMidnight dayEnd = dayStart.plusDays(1);
        days[i] = createDay(dayStart, dayEnd);

        dayStart = dayEnd;
    }
}
 
开发者ID:hongliangpan,项目名称:manydesigns.cn,代码行数:17,代码来源:AbstractWeek.java

示例2: AbstractMonth

import org.joda.time.DateMidnight; //导入方法依赖的package包/类
public AbstractMonth(DateMidnight referenceDateMidnight) {
    logger.debug("Initializing month");
    this.referenceDateMidnight = referenceDateMidnight;
    logger.debug("Reference date midnight: {}", referenceDateMidnight);

    monthStart = referenceDateMidnight.withDayOfMonth(1);
    monthEnd = monthStart.plusMonths(1);
    monthInterval = new Interval(monthStart, monthEnd);
    logger.debug("Month interval: {}", monthInterval);

    daysCount = Days.daysIn(monthInterval).getDays();
    logger.debug("Initializing {} days", daysCount);

    days = createDaysArray(daysCount);
    DateMidnight dayStart = monthStart;
    for (int i = 0; i < daysCount; i++) {
        DateMidnight dayEnd = dayStart.plusDays(1);
        days[i] = createDay(dayStart, dayEnd);

        // advance to next day
        dayStart = dayEnd;
    }
}
 
开发者ID:hongliangpan,项目名称:manydesigns.cn,代码行数:24,代码来源:AbstractMonth.java

示例3: getWeekDays

import org.joda.time.DateMidnight; //导入方法依赖的package包/类
/**
 * Note: the start date must be before or equal the end date; this is validated prior to that method
 *
 * <p>This method calculates how many weekdays are between declared start date and end date (official holidays are
 * ignored here)</p>
 *
 * @param  startDate
 * @param  endDate
 *
 * @return  number of weekdays
 */
public double getWeekDays(DateMidnight startDate, DateMidnight endDate) {

    double workDays = 0.0;

    if (!startDate.equals(endDate)) {
        DateMidnight day = startDate;

        while (!day.isAfter(endDate)) {
            if (DateUtil.isWorkDay(day)) {
                workDays++;
            }

            day = day.plusDays(1);
        }
    } else {
        if (DateUtil.isWorkDay(startDate)) {
            workDays++;
        }
    }

    return workDays;
}
 
开发者ID:synyx,项目名称:urlaubsverwaltung,代码行数:34,代码来源:WorkDaysService.java

示例4: ensureGeneratedFullDayApplicationForLeaveHasCorrectPeriod

import org.joda.time.DateMidnight; //导入方法依赖的package包/类
@Test
public void ensureGeneratedFullDayApplicationForLeaveHasCorrectPeriod() {

    DateMidnight startDate = DateMidnight.now();
    DateMidnight endDate = startDate.plusDays(3);

    ApplicationForLeaveForm form = new ApplicationForLeaveForm();

    form.setVacationType(TestDataCreator.createVacationType(VacationCategory.HOLIDAY));
    form.setDayLength(DayLength.FULL);
    form.setStartDate(startDate);
    form.setEndDate(endDate);

    Application application = form.generateApplicationForLeave();

    Assert.assertEquals("Wrong start date", startDate, application.getStartDate());
    Assert.assertEquals("Wrong end date", endDate, application.getEndDate());
    Assert.assertEquals("Wrong day length", DayLength.FULL, application.getDayLength());
}
 
开发者ID:synyx,项目名称:urlaubsverwaltung,代码行数:20,代码来源:ApplicationForLeaveFormTest.java

示例5: ensureGetPeriodReturnsCorrectPeriod

import org.joda.time.DateMidnight; //导入方法依赖的package包/类
@Test
public void ensureGetPeriodReturnsCorrectPeriod() {

    DateMidnight startDate = DateMidnight.now();
    DateMidnight endDate = startDate.plusDays(2);

    Application application = new Application();
    application.setStartDate(startDate);
    application.setEndDate(endDate);
    application.setDayLength(DayLength.FULL);

    Period period = application.getPeriod();

    Assert.assertNotNull("Period should not be null", period);
    Assert.assertEquals("Wrong period start date", startDate, period.getStartDate());
    Assert.assertEquals("Wrong period end date", endDate, period.getEndDate());
    Assert.assertEquals("Wrong period day length", DayLength.FULL, period.getDayLength());
}
 
开发者ID:synyx,项目名称:urlaubsverwaltung,代码行数:19,代码来源:ApplicationTest.java

示例6: ensureCanPersistOvertime

import org.joda.time.DateMidnight; //导入方法依赖的package包/类
@Test
@Rollback
@Ignore("Currently disabled as integration tests broke during the migration to Spring Boot.")
public void ensureCanPersistOvertime() {

    Person person = TestDataCreator.createPerson();
    personDAO.save(person);

    DateMidnight now = DateMidnight.now();
    Overtime overtime = new Overtime(person, now, now.plusDays(2), BigDecimal.ONE);

    Assert.assertNull("Must not have ID", overtime.getId());

    overtimeDAO.save(overtime);

    Assert.assertNotNull("Missing ID", overtime.getId());
}
 
开发者ID:synyx,项目名称:urlaubsverwaltung,代码行数:18,代码来源:OvertimeDAOIT.java

示例7: ensureGetPeriodReturnsCorrectPeriod

import org.joda.time.DateMidnight; //导入方法依赖的package包/类
@Test
public void ensureGetPeriodReturnsCorrectPeriod() {

    DateMidnight startDate = DateMidnight.now();
    DateMidnight endDate = startDate.plusDays(2);

    SickNote sickNote = new SickNote();
    sickNote.setStartDate(startDate);
    sickNote.setEndDate(endDate);
    sickNote.setDayLength(DayLength.FULL);

    Period period = sickNote.getPeriod();

    Assert.assertNotNull("Period should not be null", period);
    Assert.assertEquals("Wrong period start date", startDate, period.getStartDate());
    Assert.assertEquals("Wrong period end date", endDate, period.getEndDate());
    Assert.assertEquals("Wrong period day length", DayLength.FULL, period.getDayLength());
}
 
开发者ID:synyx,项目名称:urlaubsverwaltung,代码行数:19,代码来源:SickNoteTest.java

示例8: fillStats

import org.joda.time.DateMidnight; //导入方法依赖的package包/类
private void fillStats(List<Status> list, Map<DateMidnight, Integer> map, DateMidnight start, DateMidnight end) {
    LinkedList<Status> linkedList = new LinkedList<Status>(list);
    Iterator<Status> iterator = linkedList.descendingIterator();
    if (!iterator.hasNext()) {
        return;
    }

    Multiset<DateMidnight> data = LinkedHashMultiset.create();

    Status currentStatus = iterator.next();
    DateMidnight current = new DateMidnight(currentStatus.getCreatedAt());
    while (iterator.hasNext() || currentStatus != null) {
        DateMidnight msgTime = new DateMidnight(currentStatus.getCreatedAt());
        if (current.equals(msgTime)) {
            data.add(current);
            if (iterator.hasNext()) {
                currentStatus = iterator.next();
            } else {
                currentStatus = null;
            }
        } else {
            current = current.plusDays(1);
        }
    }

    for (DateMidnight dm = start; !dm.isAfter(end); dm = dm.plusDays(1)) {
        map.put(dm, data.count(dm));
    }
}
 
开发者ID:Glamdring,项目名称:welshare,代码行数:30,代码来源:TwitterService.java

示例9: testMaximumValue

import org.joda.time.DateMidnight; //导入方法依赖的package包/类
public void testMaximumValue() {
    DateMidnight dt = new DateMidnight(1570, 1, 1, GJChronology.getInstance());
    while (dt.getYear() < 1590) {
        dt = dt.plusDays(1);
        YearMonthDay ymd = dt.toYearMonthDay();
        assertEquals(dt.year().getMaximumValue(), ymd.year().getMaximumValue());
        assertEquals(dt.monthOfYear().getMaximumValue(), ymd.monthOfYear().getMaximumValue());
        assertEquals(dt.dayOfMonth().getMaximumValue(), ymd.dayOfMonth().getMaximumValue());
    }
}
 
开发者ID:SpoonLabs,项目名称:astor,代码行数:11,代码来源:TestGJChronology.java

示例10: testMaximumValue

import org.joda.time.DateMidnight; //导入方法依赖的package包/类
public void testMaximumValue() {
    DateMidnight dt = new DateMidnight(1570, 1, 1);
    while (dt.getYear() < 1590) {
        dt = dt.plusDays(1);
        YearMonthDay ymd = dt.toYearMonthDay();
        assertEquals(dt.year().getMaximumValue(), ymd.year().getMaximumValue());
        assertEquals(dt.monthOfYear().getMaximumValue(), ymd.monthOfYear().getMaximumValue());
        assertEquals(dt.dayOfMonth().getMaximumValue(), ymd.dayOfMonth().getMaximumValue());
    }
}
 
开发者ID:SpoonLabs,项目名称:astor,代码行数:11,代码来源:TestISOChronology.java

示例11: addEvent

import org.joda.time.DateMidnight; //导入方法依赖的package包/类
public int addEvent(Event event) {
    DateMidnight day = new DateMidnight(event.getInterval().getStart());
    DateTime end = event.getInterval().getEnd();
    int added = 0;
    while(end.minus(1).compareTo(day) >= 0) {
        if(addEvent(day, event)) {
            added++;
        }
        day = day.plusDays(1);
    }
    return added;
}
 
开发者ID:hongliangpan,项目名称:manydesigns.cn,代码行数:13,代码来源:AgendaView.java

示例12: validateAUPeriod

import org.joda.time.DateMidnight; //导入方法依赖的package包/类
private void validateAUPeriod(SickNote sickNote, Errors errors) {

        DayLength dayLength = sickNote.getDayLength();
        DateMidnight aubStartDate = sickNote.getAubStartDate();
        DateMidnight aubEndDate = sickNote.getAubEndDate();

        validateNotNull(aubStartDate, ATTRIBUTE_AUB_START_DATE, errors);
        validateNotNull(aubEndDate, ATTRIBUTE_AUB_END_DATE, errors);

        if (aubStartDate != null && aubEndDate != null) {
            validatePeriod(aubStartDate, aubEndDate, dayLength, ATTRIBUTE_AUB_END_DATE, errors);

            DateMidnight startDate = sickNote.getStartDate();
            DateMidnight endDate = sickNote.getEndDate();

            if (startDate != null && endDate != null && endDate.isAfter(startDate)) {
                // Intervals are inclusive of the start instant and exclusive of the end, i.e. add one day at the end
                Interval interval = new Interval(startDate, endDate.plusDays(1));

                if (!interval.contains(aubStartDate)) {
                    errors.rejectValue(ATTRIBUTE_AUB_START_DATE, ERROR_PERIOD_SICK_NOTE);
                }

                if (!interval.contains(aubEndDate)) {
                    errors.rejectValue(ATTRIBUTE_AUB_END_DATE, ERROR_PERIOD_SICK_NOTE);
                }
            }
        }
    }
 
开发者ID:synyx,项目名称:urlaubsverwaltung,代码行数:30,代码来源:SickNoteValidator.java

示例13: getSickNotes

import org.joda.time.DateMidnight; //导入方法依赖的package包/类
private List<DayAbsence> getSickNotes(DateMidnight start, DateMidnight end, Person person) {

        List<DayAbsence> absences = new ArrayList<>();

        List<SickNote> sickNotes = sickNoteService.getByPersonAndPeriod(person, start, end)
                .stream()
                .filter(SickNote::isActive)
                .collect(Collectors.toList());

        for (SickNote sickNote : sickNotes) {
            DateMidnight startDate = sickNote.getStartDate();
            DateMidnight endDate = sickNote.getEndDate();

            DateMidnight day = startDate;

            while (!day.isAfter(endDate)) {
                if (!day.isBefore(start) && !day.isAfter(end)) {
                    absences.add(new DayAbsence(day, sickNote.getDayLength(), DayAbsence.Type.SICK_NOTE, "ACTIVE",
                            sickNote.getId()));
                }

                day = day.plusDays(1);
            }
        }

        return absences;
    }
 
开发者ID:synyx,项目名称:urlaubsverwaltung,代码行数:28,代码来源:AbsenceController.java

示例14: ensureReturnsCorrectStartDate

import org.joda.time.DateMidnight; //导入方法依赖的package包/类
@Test
public void ensureReturnsCorrectStartDate() {

    Person person = TestDataCreator.createPerson();
    DateMidnight now = DateMidnight.now();

    Overtime overtime = new Overtime(person, now, now.plusDays(2), BigDecimal.ONE);

    Assert.assertNotNull("Should not be null", overtime.getStartDate());
    Assert.assertEquals("Wrong start date", now, overtime.getStartDate());
}
 
开发者ID:synyx,项目名称:urlaubsverwaltung,代码行数:12,代码来源:OvertimeTest.java

示例15: ensureSetLastModificationDateOnInitialization

import org.joda.time.DateMidnight; //导入方法依赖的package包/类
@Test
public void ensureSetLastModificationDateOnInitialization() {

    Person person = TestDataCreator.createPerson();
    DateMidnight now = DateMidnight.now();

    Overtime overtime = new Overtime(person, now.minusDays(2), now.plusDays(4), BigDecimal.ONE);

    Assert.assertNotNull("Should not be null", overtime.getLastModificationDate());
    Assert.assertEquals("Wrong last modification date", now, overtime.getLastModificationDate());
}
 
开发者ID:synyx,项目名称:urlaubsverwaltung,代码行数:12,代码来源:OvertimeTest.java


注:本文中的org.joda.time.DateMidnight.plusDays方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。