本文整理了Java中org.threeten.bp.LocalDate.plusWeeks()
方法的一些代码示例,展示了LocalDate.plusWeeks()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。LocalDate.plusWeeks()
方法的具体详情如下:
包路径:org.threeten.bp.LocalDate
类名称:LocalDate
方法名:plusWeeks
[英]Returns a copy of this LocalDate with the specified period in weeks added.
This method adds the specified amount in weeks to the days field incrementing the month and year fields as necessary to ensure the result remains valid. The result is only invalid if the maximum/minimum year is exceeded.
For example, 2008-12-31 plus one week would result in 2009-01-07.
This instance is immutable and unaffected by this method call.
[中]返回此LocalDate的副本,并添加指定的时间段(以周为单位)。
此方法将以周为单位的指定金额添加到“天”字段中,并根据需要增加“月”和“年”字段,以确保结果仍然有效。仅当超过最大/最小年份时,结果才无效。
例如,2008-12-31再加上一周将导致2009-01-07。
此实例是不可变的,不受此方法调用的影响。
代码示例来源:origin: prolificinteractive/material-calendarview
@Override public CalendarDay getItem(final int position) {
return CalendarDay.from(min.getDate().plusWeeks(position));
}
代码示例来源:origin: org.threeten/threetenbp
/**
* Returns a copy of this {@code LocalDate} with the specified period in weeks subtracted.
* <p>
* This method subtracts the specified amount in weeks from the days field decrementing
* the month and year fields as necessary to ensure the result remains valid.
* The result is only invalid if the maximum/minimum year is exceeded.
* <p>
* For example, 2009-01-07 minus one week would result in 2008-12-31.
* <p>
* This instance is immutable and unaffected by this method call.
*
* @param weeksToSubtract the weeks to subtract, may be negative
* @return a {@code LocalDate} based on this date with the weeks subtracted, not null
* @throws DateTimeException if the result exceeds the supported date range
*/
public LocalDate minusWeeks(long weeksToSubtract) {
return (weeksToSubtract == Long.MIN_VALUE ? plusWeeks(Long.MAX_VALUE).plusWeeks(1) : plusWeeks(-weeksToSubtract));
}
代码示例来源:origin: ThreeTen/threetenbp
/**
* Returns a copy of this {@code LocalDate} with the specified period in weeks subtracted.
* <p>
* This method subtracts the specified amount in weeks from the days field decrementing
* the month and year fields as necessary to ensure the result remains valid.
* The result is only invalid if the maximum/minimum year is exceeded.
* <p>
* For example, 2009-01-07 minus one week would result in 2008-12-31.
* <p>
* This instance is immutable and unaffected by this method call.
*
* @param weeksToSubtract the weeks to subtract, may be negative
* @return a {@code LocalDate} based on this date with the weeks subtracted, not null
* @throws DateTimeException if the result exceeds the supported date range
*/
public LocalDate minusWeeks(long weeksToSubtract) {
return (weeksToSubtract == Long.MIN_VALUE ? plusWeeks(Long.MAX_VALUE).plusWeeks(1) : plusWeeks(-weeksToSubtract));
}
代码示例来源:origin: ThreeTen/threetenbp
/**
* Returns a copy of this {@code LocalDateTime} with the specified period in weeks added.
* <p>
* This method adds the specified amount in weeks to the days field incrementing
* the month and year fields as necessary to ensure the result remains valid.
* The result is only invalid if the maximum/minimum year is exceeded.
* <p>
* For example, 2008-12-31 plus one week would result in 2009-01-07.
* <p>
* This instance is immutable and unaffected by this method call.
*
* @param weeks the weeks to add, may be negative
* @return a {@code LocalDateTime} based on this date-time with the weeks added, not null
* @throws DateTimeException if the result exceeds the supported date range
*/
public LocalDateTime plusWeeks(long weeks) {
LocalDate newDate = date.plusWeeks(weeks);
return with(newDate, time);
}
代码示例来源:origin: org.threeten/threetenbp
/**
* Returns a copy of this {@code LocalDateTime} with the specified period in weeks added.
* <p>
* This method adds the specified amount in weeks to the days field incrementing
* the month and year fields as necessary to ensure the result remains valid.
* The result is only invalid if the maximum/minimum year is exceeded.
* <p>
* For example, 2008-12-31 plus one week would result in 2009-01-07.
* <p>
* This instance is immutable and unaffected by this method call.
*
* @param weeks the weeks to add, may be negative
* @return a {@code LocalDateTime} based on this date-time with the weeks added, not null
* @throws DateTimeException if the result exceeds the supported date range
*/
public LocalDateTime plusWeeks(long weeks) {
LocalDate newDate = date.plusWeeks(weeks);
return with(newDate, time);
}
代码示例来源:origin: ThreeTen/threetenbp
dow = (dow % 7) + 7;
date = LocalDate.of(wby, 1, 4).plusWeeks(wowby - 1).plusWeeks(weeks).with(DAY_OF_WEEK, dow);
} else {
int dow = DAY_OF_WEEK.checkValidIntValue(dowLong);
range().checkValidValue(wowby, this); // leniently check from 1 to 53
date = LocalDate.of(wby, 1, 4).plusWeeks(wowby - 1).with(DAY_OF_WEEK, dow);
代码示例来源:origin: org.threeten/threetenbp
dow = (dow % 7) + 7;
date = LocalDate.of(wby, 1, 4).plusWeeks(wowby - 1).plusWeeks(weeks).with(DAY_OF_WEEK, dow);
} else {
int dow = DAY_OF_WEEK.checkValidIntValue(dowLong);
range().checkValidValue(wowby, this); // leniently check from 1 to 53
date = LocalDate.of(wby, 1, 4).plusWeeks(wowby - 1).with(DAY_OF_WEEK, dow);
代码示例来源:origin: ThreeTen/threetenbp
long weeks = Jdk8Methods.safeSubtract(fieldValues.remove(ALIGNED_WEEK_OF_MONTH), 1);
long days = Jdk8Methods.safeSubtract(fieldValues.remove(ALIGNED_DAY_OF_WEEK_IN_MONTH), 1);
return LocalDate.of(y, 1, 1).plusMonths(months).plusWeeks(weeks).plusDays(days);
long weeks = Jdk8Methods.safeSubtract(fieldValues.remove(ALIGNED_WEEK_OF_MONTH), 1);
long days = Jdk8Methods.safeSubtract(fieldValues.remove(DAY_OF_WEEK), 1);
return LocalDate.of(y, 1, 1).plusMonths(months).plusWeeks(weeks).plusDays(days);
LocalDate date = LocalDate.of(y, moy, 1).plusWeeks(aw - 1).with(nextOrSame(DayOfWeek.of(dow)));
if (resolverStyle == ResolverStyle.STRICT && date.get(MONTH_OF_YEAR) != moy) {
throw new DateTimeException("Strict mode rejected date parsed to a different month");
long weeks = Jdk8Methods.safeSubtract(fieldValues.remove(ALIGNED_WEEK_OF_YEAR), 1);
long days = Jdk8Methods.safeSubtract(fieldValues.remove(ALIGNED_DAY_OF_WEEK_IN_YEAR), 1);
return LocalDate.of(y, 1, 1).plusWeeks(weeks).plusDays(days);
long weeks = Jdk8Methods.safeSubtract(fieldValues.remove(ALIGNED_WEEK_OF_YEAR), 1);
long days = Jdk8Methods.safeSubtract(fieldValues.remove(DAY_OF_WEEK), 1);
return LocalDate.of(y, 1, 1).plusWeeks(weeks).plusDays(days);
LocalDate date = LocalDate.of(y, 1, 1).plusWeeks(aw - 1).with(nextOrSame(DayOfWeek.of(dow)));
if (resolverStyle == ResolverStyle.STRICT && date.get(YEAR) != y) {
throw new DateTimeException("Strict mode rejected date parsed to a different month");
代码示例来源:origin: org.threeten/threetenbp
long weeks = Jdk8Methods.safeSubtract(fieldValues.remove(ALIGNED_WEEK_OF_MONTH), 1);
long days = Jdk8Methods.safeSubtract(fieldValues.remove(ALIGNED_DAY_OF_WEEK_IN_MONTH), 1);
return LocalDate.of(y, 1, 1).plusMonths(months).plusWeeks(weeks).plusDays(days);
long weeks = Jdk8Methods.safeSubtract(fieldValues.remove(ALIGNED_WEEK_OF_MONTH), 1);
long days = Jdk8Methods.safeSubtract(fieldValues.remove(DAY_OF_WEEK), 1);
return LocalDate.of(y, 1, 1).plusMonths(months).plusWeeks(weeks).plusDays(days);
LocalDate date = LocalDate.of(y, moy, 1).plusWeeks(aw - 1).with(nextOrSame(DayOfWeek.of(dow)));
if (resolverStyle == ResolverStyle.STRICT && date.get(MONTH_OF_YEAR) != moy) {
throw new DateTimeException("Strict mode rejected date parsed to a different month");
long weeks = Jdk8Methods.safeSubtract(fieldValues.remove(ALIGNED_WEEK_OF_YEAR), 1);
long days = Jdk8Methods.safeSubtract(fieldValues.remove(ALIGNED_DAY_OF_WEEK_IN_YEAR), 1);
return LocalDate.of(y, 1, 1).plusWeeks(weeks).plusDays(days);
long weeks = Jdk8Methods.safeSubtract(fieldValues.remove(ALIGNED_WEEK_OF_YEAR), 1);
long days = Jdk8Methods.safeSubtract(fieldValues.remove(DAY_OF_WEEK), 1);
return LocalDate.of(y, 1, 1).plusWeeks(weeks).plusDays(days);
LocalDate date = LocalDate.of(y, 1, 1).plusWeeks(aw - 1).with(nextOrSame(DayOfWeek.of(dow)));
if (resolverStyle == ResolverStyle.STRICT && date.get(YEAR) != y) {
throw new DateTimeException("Strict mode rejected date parsed to a different month");
代码示例来源:origin: ThreeTen/threetenbp
switch (f) {
case DAYS: return plusDays(amountToAdd);
case WEEKS: return plusWeeks(amountToAdd);
case MONTHS: return plusMonths(amountToAdd);
case YEARS: return plusYears(amountToAdd);
代码示例来源:origin: org.threeten/threetenbp
switch (f) {
case DAYS: return plusDays(amountToAdd);
case WEEKS: return plusWeeks(amountToAdd);
case MONTHS: return plusMonths(amountToAdd);
case YEARS: return plusYears(amountToAdd);
代码示例来源:origin: org.threeten/threetenbp
case DAY_OF_YEAR: return withDayOfYear((int) newValue);
case EPOCH_DAY: return LocalDate.ofEpochDay(newValue);
case ALIGNED_WEEK_OF_MONTH: return plusWeeks(newValue - getLong(ALIGNED_WEEK_OF_MONTH));
case ALIGNED_WEEK_OF_YEAR: return plusWeeks(newValue - getLong(ALIGNED_WEEK_OF_YEAR));
case MONTH_OF_YEAR: return withMonth((int) newValue);
case PROLEPTIC_MONTH: return plusMonths(newValue - getLong(PROLEPTIC_MONTH));
代码示例来源:origin: ThreeTen/threetenbp
case DAY_OF_YEAR: return withDayOfYear((int) newValue);
case EPOCH_DAY: return LocalDate.ofEpochDay(newValue);
case ALIGNED_WEEK_OF_MONTH: return plusWeeks(newValue - getLong(ALIGNED_WEEK_OF_MONTH));
case ALIGNED_WEEK_OF_YEAR: return plusWeeks(newValue - getLong(ALIGNED_WEEK_OF_YEAR));
case MONTH_OF_YEAR: return withMonth((int) newValue);
case PROLEPTIC_MONTH: return plusMonths(newValue - getLong(PROLEPTIC_MONTH));
内容来源于网络,如有侵权,请联系作者删除!