本文整理汇总了Java中org.joda.time.DateMidnight.getDayOfWeek方法的典型用法代码示例。如果您正苦于以下问题:Java DateMidnight.getDayOfWeek方法的具体用法?Java DateMidnight.getDayOfWeek怎么用?Java DateMidnight.getDayOfWeek使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.joda.time.DateMidnight
的用法示例。
在下文中一共展示了DateMidnight.getDayOfWeek方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getWorkDays
import org.joda.time.DateMidnight; //导入方法依赖的package包/类
/**
* This method calculates how many workdays are used in the stated period (from start date to end date) considering
* the personal working time of the given person, getNumberOfPublicHolidays calculates the number of official
* holidays within the personal workdays period. Number of workdays results from difference between personal
* workdays and official holidays.
*
* @param dayLength
* @param startDate
* @param endDate
* @param person
*
* @return number of workdays
*/
public BigDecimal getWorkDays(DayLength dayLength, DateMidnight startDate, DateMidnight endDate, Person person) {
Optional<WorkingTime> optionalWorkingTime = workingTimeService.getByPersonAndValidityDateEqualsOrMinorDate(
person, startDate);
if (!optionalWorkingTime.isPresent()) {
throw new NoValidWorkingTimeException("No working time found for User '" + person.getLoginName()
+ "' in period " + startDate.toString(DateFormat.PATTERN) + " - "
+ endDate.toString(DateFormat.PATTERN));
}
WorkingTime workingTime = optionalWorkingTime.get();
FederalState federalState = getFederalState(workingTime);
BigDecimal vacationDays = BigDecimal.ZERO;
DateMidnight day = startDate;
while (!day.isAfter(endDate)) {
// value may be 1 for public holiday, 0 for not public holiday or 0.5 for Christmas Eve or New Year's Eve
BigDecimal duration = publicHolidaysService.getWorkingDurationOfDate(day, federalState);
int dayOfWeek = day.getDayOfWeek();
BigDecimal workingDuration = workingTime.getDayLengthForWeekDay(dayOfWeek).getDuration();
BigDecimal result = duration.multiply(workingDuration);
vacationDays = vacationDays.add(result);
day = day.plusDays(1);
}
// vacation days < 1 day --> must not be divided, else an ArithmeticException is thrown
if (vacationDays.compareTo(BigDecimal.ONE) < 0) {
return vacationDays.setScale(1);
}
return vacationDays.multiply(dayLength.getDuration()).setScale(1);
}
示例2: isWorkDay
import org.joda.time.DateMidnight; //导入方法依赖的package包/类
/**
* Check if the given date is a work day.
*
* @param date
* to check
*
* @return {@code true} if the given date is a work day, else {@code false}
*/
public static boolean isWorkDay(DateMidnight date) {
return !(date.getDayOfWeek() == DateTimeConstants.SATURDAY || date.getDayOfWeek() == DateTimeConstants.SUNDAY);
}