java.time.OffsetDateTime.plusWeeks()方法的使用及代码示例

x33g5p2x  于2022-01-25 转载在 其他  
字(1.9k)|赞(0)|评价(0)|浏览(150)

本文整理了Java中java.time.OffsetDateTime.plusWeeks()方法的一些代码示例,展示了OffsetDateTime.plusWeeks()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。OffsetDateTime.plusWeeks()方法的具体详情如下:
包路径:java.time.OffsetDateTime
类名称:OffsetDateTime
方法名:plusWeeks

OffsetDateTime.plusWeeks介绍

[英]Returns a copy of this OffsetDateTime 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 the 2009-01-07.

This instance is immutable and unaffected by this method call.
[中]返回此OffsetDateTime的副本,并添加指定的时间段(以周为单位)。
此方法将以周为单位的指定金额添加到“天”字段中,并根据需要增加“月”和“年”字段,以确保结果仍然有效。仅当超过最大/最小年份时,结果才无效。
例如,2008-12-31再加上一周将导致2009-01-07。
此实例是不可变的,不受此方法调用的影响。

代码示例

代码示例来源:origin: com.github.seratch/java-time-backport

/**
 * Returns a copy of this {@code OffsetDateTime} 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, 2008-12-31 minus one week would result in the 2009-01-07.
 * <p>
 * This instance is immutable and unaffected by this method call.
 *
 * @param weeks  the weeks to subtract, may be negative
 * @return an {@code OffsetDateTime} based on this date-time with the weeks subtracted, not null
 * @throws DateTimeException if the result exceeds the supported date range
 */
public OffsetDateTime minusWeeks(long weeks) {
  return (weeks == Long.MIN_VALUE ? plusWeeks(Long.MAX_VALUE).plusWeeks(1) : plusWeeks(-weeks));
}

代码示例来源:origin: FlareBot/FlareBot

if (msg.getCreationTime().plusWeeks(2).isBefore(OffsetDateTime.now())) break outer;
if (msg.getId().equals(message.getId())) continue;
if ((targetUser != null && msg.getAuthor().getId().equals(targetUser.getId())) || targetUser == null) {

相关文章