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


Java DateMidnight.getDayOfWeek方法代码示例

本文整理汇总了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);
}
 
开发者ID:synyx,项目名称:urlaubsverwaltung,代码行数:54,代码来源:WorkDaysService.java

示例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);
}
 
开发者ID:synyx,项目名称:urlaubsverwaltung,代码行数:13,代码来源:DateUtil.java


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