本文整理汇总了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;
}
}
示例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;
}
}
示例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;
}
示例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());
}
示例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());
}
示例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());
}
示例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());
}
示例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));
}
}
示例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());
}
}
示例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());
}
}
示例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;
}
示例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);
}
}
}
}
示例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;
}
示例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());
}
示例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());
}