本文整理汇总了Java中org.joda.time.DateMidnight.getYear方法的典型用法代码示例。如果您正苦于以下问题:Java DateMidnight.getYear方法的具体用法?Java DateMidnight.getYear怎么用?Java DateMidnight.getYear使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.joda.time.DateMidnight
的用法示例。
在下文中一共展示了DateMidnight.getYear方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: validatePeriod
import org.joda.time.DateMidnight; //导入方法依赖的package包/类
void validatePeriod(AccountForm form, Errors errors) {
DateMidnight holidaysAccountValidFrom = form.getHolidaysAccountValidFrom();
DateMidnight holidaysAccountValidTo = form.getHolidaysAccountValidTo();
validateDateNotNull(holidaysAccountValidFrom, "holidaysAccountValidFrom", errors);
validateDateNotNull(holidaysAccountValidTo, "holidaysAccountValidTo", errors);
if (holidaysAccountValidFrom != null && holidaysAccountValidTo != null) {
boolean periodIsNotWithinOneYear = holidaysAccountValidFrom.getYear() != form.getHolidaysAccountYear()
|| holidaysAccountValidTo.getYear() != form.getHolidaysAccountYear();
boolean periodIsOnlyOneDay = holidaysAccountValidFrom.equals(holidaysAccountValidTo);
boolean beginOfPeriodIsAfterEndOfPeriod = holidaysAccountValidFrom.isAfter(holidaysAccountValidTo);
if (periodIsNotWithinOneYear || periodIsOnlyOneDay || beginOfPeriodIsAfterEndOfPeriod) {
errors.reject(ERROR_PERIOD);
}
}
}
示例2: 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());
}
}
示例3: 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());
}
}
示例4: applicationForLeaveStatistics
import org.joda.time.DateMidnight; //导入方法依赖的package包/类
@PreAuthorize(SecurityRules.IS_PRIVILEGED_USER)
@RequestMapping(value = "/statistics", method = RequestMethod.GET)
public String applicationForLeaveStatistics(@RequestParam(value = "from", required = false) String from,
@RequestParam(value = "to", required = false) String to, Model model) {
FilterPeriod period = new FilterPeriod(Optional.ofNullable(from), Optional.ofNullable(to));
DateMidnight fromDate = period.getStartDate();
DateMidnight toDate = period.getEndDate();
// NOTE: Not supported at the moment
if (fromDate.getYear() != toDate.getYear()) {
model.addAttribute("period", period);
model.addAttribute(ControllerConstants.ERRORS_ATTRIBUTE, "INVALID_PERIOD");
return "application/app_statistics";
}
List<Person> persons = getRelevantPersons();
List<ApplicationForLeaveStatistics> statistics = persons.stream().map(person ->
applicationForLeaveStatisticsBuilder.build(person, fromDate, toDate)).collect(Collectors.toList());
model.addAttribute("from", fromDate);
model.addAttribute("to", toDate);
model.addAttribute("statistics", statistics);
model.addAttribute("period", period);
model.addAttribute("vacationTypes", vacationTypeService.getVacationTypes());
return "application/app_statistics";
}
示例5: getVacationOverviews
import org.joda.time.DateMidnight; //导入方法依赖的package包/类
public List<VacationOverview> getVacationOverviews(String selectedDepartment,
Integer selectedYear,
Integer selectedMonth) {
List<VacationOverview> holidayOverviewList = new ArrayList<>();
Department department = getDepartmentByName(selectedDepartment);
if (department != null) {
for (Person person : department.getMembers()) {
DateMidnight date = new DateMidnight();
int year = selectedYear != null ? selectedYear : date.getYear();
int month = selectedMonth != null ? selectedMonth : date.getMonthOfYear();
DateMidnight lastDay = DateUtil.getLastDayOfMonth(year, month);
VacationOverview holidayOverview = getVacationOverview(person);
for (int i = 1; i <= lastDay.toDate().getDate(); i++) {
DayOfMonth dayOfMonth = new DayOfMonth();
DateMidnight currentDay = new DateMidnight(year, month, i);
dayOfMonth.setDayText(currentDay.toString(DATE_FORMAT));
dayOfMonth.setDayNumber(i);
dayOfMonth.setTypeOfDay(getTypeOfDay(person, currentDay));
holidayOverview.getDays().add(dayOfMonth);
}
holidayOverviewList.add(holidayOverview);
}
}
return holidayOverviewList;
}
示例6: checkApplication
import org.joda.time.DateMidnight; //导入方法依赖的package包/类
/**
* Checks if applying for leave is possible, i.e. there are enough vacation days left to be used for the given
* {@link org.synyx.urlaubsverwaltung.core.application.domain.Application} for leave.
*
* @param application for leave to check
*
* @return {@code true} if the {@link org.synyx.urlaubsverwaltung.core.application.domain.Application} for leave
* may be saved because there are enough vacation days left, {@code false} else
*/
public boolean checkApplication(Application application) {
Person person = application.getPerson();
DayLength dayLength = application.getDayLength();
DateMidnight startDate = application.getStartDate();
DateMidnight endDate = application.getEndDate();
int yearOfStartDate = startDate.getYear();
int yearOfEndDate = endDate.getYear();
if (yearOfStartDate == yearOfEndDate) {
BigDecimal workDays = calendarService.getWorkDays(dayLength, startDate, endDate, person);
Optional<Account> holidaysAccount = getHolidaysAccount(yearOfStartDate, person);
return holidaysAccount.isPresent()
&& vacationDaysService.calculateTotalLeftVacationDays(holidaysAccount.get()).compareTo(workDays) >= 0;
} else {
// ensure that applying for leave for the period in the old year is possible
BigDecimal workDaysInOldYear = calendarService.getWorkDays(dayLength, startDate,
DateUtil.getLastDayOfYear(yearOfStartDate), person);
// ensure that applying for leave for the period in the new year is possible
BigDecimal workDaysInNewYear = calendarService.getWorkDays(dayLength,
DateUtil.getFirstDayOfYear(yearOfEndDate), endDate, person);
Optional<Account> holidaysAccountForOldYear = getHolidaysAccount(yearOfStartDate, person);
Optional<Account> holidaysAccountForNewYear = getHolidaysAccount(yearOfEndDate, person);
return accountHasEnoughVacationDaysLeft(holidaysAccountForOldYear, workDaysInOldYear)
&& accountHasEnoughVacationDaysLeft(holidaysAccountForNewYear, workDaysInNewYear);
}
}
示例7: calculateTotalNumberOfSickDays
import org.joda.time.DateMidnight; //导入方法依赖的package包/类
private BigDecimal calculateTotalNumberOfSickDays(WorkDaysService calendarService, List<SickNote> sickNotes) {
BigDecimal numberOfSickDays = BigDecimal.ZERO;
for (SickNote sickNote : sickNotes) {
DateMidnight sickNoteStartDate = sickNote.getStartDate();
DateMidnight sickNoteEndDate = sickNote.getEndDate();
DateMidnight startDate;
DateMidnight endDate;
Assert.isTrue(sickNoteStartDate.getYear() == this.year || sickNoteEndDate.getYear() == this.year,
"Start date OR end date of the sick note must be in the year " + this.year);
if (sickNoteStartDate.getYear() == this.year) {
startDate = sickNoteStartDate;
} else {
startDate = sickNoteEndDate.dayOfYear().withMinimumValue();
}
if (sickNoteEndDate.getYear() == this.year) {
endDate = sickNoteEndDate;
} else {
endDate = sickNoteStartDate.dayOfYear().withMaximumValue();
}
BigDecimal workDays = calendarService.getWorkDays(sickNote.getDayLength(), startDate, endDate,
sickNote.getPerson());
numberOfSickDays = numberOfSickDays.add(workDays);
}
return numberOfSickDays;
}
示例8: startAndEndDatesAreInCurrentYear
import org.joda.time.DateMidnight; //导入方法依赖的package包/类
/**
* Check if the given dates are in the current year.
*
* @param start to be checked if in the current year
* @param end to be checked if in the current year
*
* @return {@code true} if both dates are in the current year, else {@code false}
*/
boolean startAndEndDatesAreInCurrentYear(DateMidnight start, DateMidnight end) {
int currentYear = DateMidnight.now().getYear();
return start.getYear() == currentYear && end.getYear() == currentYear;
}