本文整理汇总了Java中java.time.LocalDate.minusWeeks方法的典型用法代码示例。如果您正苦于以下问题:Java LocalDate.minusWeeks方法的具体用法?Java LocalDate.minusWeeks怎么用?Java LocalDate.minusWeeks使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.time.LocalDate
的用法示例。
在下文中一共展示了LocalDate.minusWeeks方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: calculateStartDate
import java.time.LocalDate; //导入方法依赖的package包/类
private LocalDate calculateStartDate() {
LocalDate startDate = getDate();
if (isAdjustToFirstDayOfWeek()) {
LocalDate newStartDate = startDate.with(DAY_OF_WEEK, getFirstDayOfWeek().getValue());
if (newStartDate.isAfter(startDate)) {
startDate = newStartDate.minusWeeks(1);
} else {
startDate = newStartDate;
}
}
return startDate;
}
示例2: getDate
import java.time.LocalDate; //导入方法依赖的package包/类
private LocalDate getDate(LocalDate startDate, int dayCount) {
if (getSkinnable().isAdjustToFirstDayOfWeek()) {
LocalDate newStartDate = startDate.with(DAY_OF_WEEK, getSkinnable().getFirstDayOfWeek().getValue());
if (newStartDate.isAfter(startDate)) {
startDate = newStartDate.minusWeeks(1);
} else {
startDate = newStartDate;
}
}
return startDate.plusDays(dayCount);
}
示例3: adjustToFirstDayOfWeek
import java.time.LocalDate; //导入方法依赖的package包/类
/**
* Adjusts the given date to a new date that marks the beginning of the week where the
* given date is located. If "Monday" is the first day of the week and the given date
* is a "Wednesday" then this method will return a date that is two days earlier than the
* given date.
*
* @param date the date to adjust
* @param firstDayOfWeek the day of week that is considered the start of the week ("Monday" in Germany, "Sunday" in the US)
* @return the date of the first day of the week
* @see #adjustToLastDayOfWeek(LocalDate, DayOfWeek)
* @see DateControl#getFirstDayOfWeek()
*/
public static LocalDate adjustToFirstDayOfWeek(LocalDate date, DayOfWeek firstDayOfWeek) {
LocalDate newDate = date.with(DAY_OF_WEEK, firstDayOfWeek.getValue());
if (newDate.isAfter(date)) {
newDate = newDate.minusWeeks(1);
}
return newDate;
}