當前位置: 首頁>>代碼示例>>Java>>正文


Java LocalDateTime.plusWeeks方法代碼示例

本文整理匯總了Java中java.time.LocalDateTime.plusWeeks方法的典型用法代碼示例。如果您正苦於以下問題:Java LocalDateTime.plusWeeks方法的具體用法?Java LocalDateTime.plusWeeks怎麽用?Java LocalDateTime.plusWeeks使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在java.time.LocalDateTime的用法示例。


在下文中一共展示了LocalDateTime.plusWeeks方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getAWeekFromNow

import java.time.LocalDateTime; //導入方法依賴的package包/類
/**
 * 獲得當天近一周
 * @return LocalDateTime
 */
public static LocalDateTime getAWeekFromNow() {
    LocalDateTime date = LocalDateTime.now();
    //7天前
    return date.plusWeeks(-1);
}
 
開發者ID:yu199195,項目名稱:happylifeplat-transaction,代碼行數:10,代碼來源:DateUtils.java

示例2: generateRoster

import java.time.LocalDateTime; //導入方法依賴的package包/類
@Transactional
public Roster generateRoster(int spotListSize, int timeSlotListSize, boolean continuousPlanning) {
    int employeeListSize = spotListSize * 7 / 2;
    int skillListSize = (spotListSize + 4) / 5;
    Integer tenantId = createTenant(spotListSize, employeeListSize);
    List<Skill> skillList = createSkillList(tenantId, skillListSize);
    List<Spot> spotList = createSpotList(tenantId, spotListSize, skillList);

    List<Employee> employeeList = createEmployeeList(tenantId, employeeListSize, skillList);

    shiftRestService.createTemplate(tenantId, generateShiftTemplate(tenantId, spotList, employeeList));
    LocalDateTime previousEndDateTime = LocalDateTime.of(2017, 2, 1, 6, 0);
    for (int i = 0; i < timeSlotListSize; i += 7) {
        try {
            shiftRestService.addShiftsFromTemplate(tenantId, previousEndDateTime.toString(), previousEndDateTime
                    .plusDays(7).toString());
            previousEndDateTime = previousEndDateTime.plusWeeks(1);
        } catch (Exception e) {
            throw new IllegalStateException(e);
        }
        previousEndDateTime = previousEndDateTime.plusDays(7);
    }

    List<TimeSlot> timeSlotList = entityManager.createNamedQuery("TimeSlot.findAll", TimeSlot.class)
            .setParameter("tenantId", tenantId)
            .getResultList();

    List<Shift> shiftList = entityManager.createNamedQuery("Shift.findAll", Shift.class)
            .setParameter("tenantId", tenantId)
            .getResultList();

    List<EmployeeAvailability> employeeAvailabilityList = entityManager
            .createNamedQuery("EmployeeAvailability.findAll", EmployeeAvailability.class)
            .setParameter("tenantId", tenantId)
            .getResultList();
    
    Tenant tenant = entityManager.find(Tenant.class, tenantId);

    return new Roster((long) tenantId, tenantId,
            skillList, spotList, employeeList, timeSlotList, employeeAvailabilityList, 
            tenant.getConfiguration(), shiftList);
}
 
開發者ID:kiegroup,項目名稱:optashift-employee-rostering,代碼行數:43,代碼來源:RosterGenerator.java

示例3: testClacPlus

import java.time.LocalDateTime; //導入方法依賴的package包/類
/**
 * 時間運算,計算完成後會返回新的對象,並不會改變原來的時間
 */
@Test
public void testClacPlus() {
    LocalDateTime ldt = LocalDateTime.now();

    System.out.println(ldt);

    // 加: 天
    LocalDateTime day = ldt.plusDays(1);
    System.out.println("day: " + day);

    // 加: 小時
    LocalDateTime hours = ldt.plusHours(1);
    System.out.println("hours: " + hours);

    // 加: 分鍾
    LocalDateTime minutes = ldt.plusMinutes(1);
    System.out.println("minutes: " + minutes);

    // 加: 月
    LocalDateTime months = ldt.plusMonths(1);
    System.out.println("months: " + months);

    // 加: 納秒
    LocalDateTime nanos = ldt.plusNanos(1);
    System.out.println("nanos: " + nanos);

    // 加: 秒
    LocalDateTime seconds = ldt.plusSeconds(1);
    System.out.println("seconds: " + seconds);

    // 加: 周
    LocalDateTime weeks = ldt.plusWeeks(1);
    System.out.println("weeks: " + weeks);

    // 加: 年
    LocalDateTime years = ldt.plusYears(1);
    System.out.println("years: " + years);

    System.out.println(ldt);
}
 
開發者ID:cbooy,項目名稱:cakes,代碼行數:44,代碼來源:LocalDateTimeDemo.java


注:本文中的java.time.LocalDateTime.plusWeeks方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。