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