本文整理了Java中org.joda.time.LocalDate.minusWeeks()
方法的一些代码示例,展示了LocalDate.minusWeeks()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。LocalDate.minusWeeks()
方法的具体详情如下:
包路径:org.joda.time.LocalDate
类名称:LocalDate
方法名:minusWeeks
[英]Returns a copy of this date minus the specified number of weeks.
This LocalDate instance is immutable and unaffected by this method call.
The following three lines are identical in effect:
LocalDate subtracted = dt.minusWeeks(6);
LocalDate subtracted = dt.minus(Period.weeks(6));
LocalDate subtracted = dt.withFieldAdded(DurationFieldType.weeks(), -6);
[中]返回此日期减去指定周数的副本。
此LocalDate实例是不可变的,不受此方法调用的影响。
以下三行实际上是相同的:
LocalDate subtracted = dt.minusWeeks(6);
LocalDate subtracted = dt.minus(Period.weeks(6));
LocalDate subtracted = dt.withFieldAdded(DurationFieldType.weeks(), -6);
代码示例来源:origin: nl.cloudfarming.client/calendar-api
public static LocalDate previousWeek(LocalDate actual) {
return actual.minusWeeks(1);
}
代码示例来源:origin: fluxtream/fluxtream-app
public static LocalDate getBeginningOfWeek(final int year, final int week) {
return (new LocalDate())
.withWeekyear(year)
.withWeekOfWeekyear(week)
.minusWeeks(1)
.withDayOfWeek(FIRST_DAY_OF_WEEK);
// Need to subtract 1 week because Sunday is the last day of the week, which
// would logically move all the week start dates forward by 6 days. Better
// one day earlier than JodaTime's standard than 6 days later than
// users' expectations.
}
代码示例来源:origin: yannecer/NCalendar
public static LocalDate getSunFirstDayOfWeek(LocalDate date) {
if (date.dayOfWeek().get() == 7) {
return date;
} else {
return date.minusWeeks(1).withDayOfWeek(7);
}
}
代码示例来源:origin: fluxtream/fluxtream-app
public void setWeekTimeUnit() {
LocalDate origFromDate = fromDate;
timeUnit = TimeUnit.WEEK;
fromDate = new LocalDate(fromDate.getYear(), fromDate.getMonthOfYear(), fromDate.getDayOfMonth())
.withDayOfWeek(TimeUtils.FIRST_DAY_OF_WEEK);
// Unfortunately, the above code returns the following week instead of the containing week for
// every day other than Sunday. Check for this and decrement the week if needed.
if(fromDate.isAfter(origFromDate)) {
fromDate = fromDate.minusWeeks(1);
}
}
}
代码示例来源:origin: fluxtream/fluxtream-app
public void decrementTimespan() {
switch (timeUnit) {
case DAY:
fromDate = fromDate.minusDays(1);
break;
case WEEK:
fromDate = fromDate.minusWeeks(1);
break;
case MONTH:
fromDate = fromDate.minusMonths(1);
break;
case YEAR:
fromDate = fromDate.minusYears(1);
break;
}
}
代码示例来源:origin: googleads/aw-reporting
break;
case LAST_WEEK:
LocalDate.Property lastWeekProp = today.minusWeeks(1).dayOfWeek();
startDate = lastWeekProp.withMinimumValue();
endDate = lastWeekProp.withMaximumValue();
case THIS_WEEK_SUN_TODAY:
startDate = today.minusWeeks(1).dayOfWeek().withMaximumValue();
endDate = today;
break;
break;
case LAST_WEEK_SUN_SAT:
startDate = today.minusWeeks(2).dayOfWeek().withMaximumValue();
endDate = today.minusWeeks(1).dayOfWeek().withMaximumValue().minusDays(1);
break;
内容来源于网络,如有侵权,请联系作者删除!