本文整理匯總了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;
}