本文整理了Java中org.threeten.bp.LocalDateTime.plusDays()
方法的一些代码示例,展示了LocalDateTime.plusDays()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。LocalDateTime.plusDays()
方法的具体详情如下:
包路径:org.threeten.bp.LocalDateTime
类名称:LocalDateTime
方法名:plusDays
[英]Returns a copy of this LocalDateTime with the specified period in days added.
This method adds the specified amount 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 day would result in 2009-01-01.
This instance is immutable and unaffected by this method call.
[中]返回此LocalDateTime的副本,并添加指定的期间(以天为单位)。
此方法将指定的金额添加到“天”字段中,并根据需要增加“月”和“年”字段,以确保结果仍然有效。仅当超过最大/最小年份时,结果才无效。
例如,2008-12-31加上一天将导致2009-01-01。
此实例是不可变的,不受此方法调用的影响。
代码示例来源:origin: ThreeTen/threetenbp
/**
* Returns a copy of this {@code LocalDateTime} with the specified period in days subtracted.
* <p>
* This method subtracts the specified amount from 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, 2009-01-01 minus one day would result in 2008-12-31.
* <p>
* This instance is immutable and unaffected by this method call.
*
* @param days the days to subtract, may be negative
* @return a {@code LocalDateTime} based on this date-time with the days subtracted, not null
* @throws DateTimeException if the result exceeds the supported date range
*/
public LocalDateTime minusDays(long days) {
return (days == Long.MIN_VALUE ? plusDays(Long.MAX_VALUE).plusDays(1) : plusDays(-days));
}
代码示例来源:origin: org.threeten/threetenbp
/**
* Returns a copy of this {@code LocalDateTime} with the specified period in days subtracted.
* <p>
* This method subtracts the specified amount from 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, 2009-01-01 minus one day would result in 2008-12-31.
* <p>
* This instance is immutable and unaffected by this method call.
*
* @param days the days to subtract, may be negative
* @return a {@code LocalDateTime} based on this date-time with the days subtracted, not null
* @throws DateTimeException if the result exceeds the supported date range
*/
public LocalDateTime minusDays(long days) {
return (days == Long.MIN_VALUE ? plusDays(Long.MAX_VALUE).plusDays(1) : plusDays(-days));
}
代码示例来源:origin: ThreeTen/threetenbp
/**
* Returns a copy of this OffsetDateTime with the specified period in days added.
* <p>
* This method adds the specified amount 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 day would result in the 2009-01-01.
* <p>
* This instance is immutable and unaffected by this method call.
*
* @param days the days to add, may be negative
* @return an {@code OffsetDateTime} based on this date-time with the days added, not null
* @throws DateTimeException if the result exceeds the supported date range
*/
public OffsetDateTime plusDays(long days) {
return with(dateTime.plusDays(days), offset);
}
代码示例来源:origin: org.threeten/threetenbp
/**
* Returns a copy of this OffsetDateTime with the specified period in days added.
* <p>
* This method adds the specified amount 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 day would result in the 2009-01-01.
* <p>
* This instance is immutable and unaffected by this method call.
*
* @param days the days to add, may be negative
* @return an {@code OffsetDateTime} based on this date-time with the days added, not null
* @throws DateTimeException if the result exceeds the supported date range
*/
public OffsetDateTime plusDays(long days) {
return with(dateTime.plusDays(days), offset);
}
代码示例来源:origin: ThreeTen/threetenbp
/**
* Returns a copy of this {@code ZonedDateTime} with the specified period in days added.
* <p>
* This operates on the local time-line,
* {@link LocalDateTime#plusDays(long) adding days} to the local date-time.
* This is then converted back to a {@code ZonedDateTime}, using the zone ID
* to obtain the offset.
* <p>
* When converting back to {@code ZonedDateTime}, if the local date-time is in an overlap,
* then the offset will be retained if possible, otherwise the earlier offset will be used.
* If in a gap, the local date-time will be adjusted forward by the length of the gap.
* <p>
* This instance is immutable and unaffected by this method call.
*
* @param days the days to add, may be negative
* @return a {@code ZonedDateTime} based on this date-time with the days added, not null
* @throws DateTimeException if the result exceeds the supported date range
*/
public ZonedDateTime plusDays(long days) {
return resolveLocal(dateTime.plusDays(days));
}
代码示例来源:origin: org.threeten/threetenbp
/**
* Returns a copy of this {@code ZonedDateTime} with the specified period in days added.
* <p>
* This operates on the local time-line,
* {@link LocalDateTime#plusDays(long) adding days} to the local date-time.
* This is then converted back to a {@code ZonedDateTime}, using the zone ID
* to obtain the offset.
* <p>
* When converting back to {@code ZonedDateTime}, if the local date-time is in an overlap,
* then the offset will be retained if possible, otherwise the earlier offset will be used.
* If in a gap, the local date-time will be adjusted forward by the length of the gap.
* <p>
* This instance is immutable and unaffected by this method call.
*
* @param days the days to add, may be negative
* @return a {@code ZonedDateTime} based on this date-time with the days added, not null
* @throws DateTimeException if the result exceeds the supported date range
*/
public ZonedDateTime plusDays(long days) {
return resolveLocal(dateTime.plusDays(days));
}
代码示例来源:origin: ThreeTen/threetenbp
switch (f) {
case NANOS: return plusNanos(amountToAdd);
case MICROS: return plusDays(amountToAdd / MICROS_PER_DAY).plusNanos((amountToAdd % MICROS_PER_DAY) * 1000);
case MILLIS: return plusDays(amountToAdd / MILLIS_PER_DAY).plusNanos((amountToAdd % MILLIS_PER_DAY) * 1000000);
case SECONDS: return plusSeconds(amountToAdd);
case MINUTES: return plusMinutes(amountToAdd);
case HOURS: return plusHours(amountToAdd);
case HALF_DAYS: return plusDays(amountToAdd / 256).plusHours((amountToAdd % 256) * 12); // no overflow (256 is multiple of 2)
代码示例来源:origin: org.threeten/threetenbp
switch (f) {
case NANOS: return plusNanos(amountToAdd);
case MICROS: return plusDays(amountToAdd / MICROS_PER_DAY).plusNanos((amountToAdd % MICROS_PER_DAY) * 1000);
case MILLIS: return plusDays(amountToAdd / MILLIS_PER_DAY).plusNanos((amountToAdd % MILLIS_PER_DAY) * 1000000);
case SECONDS: return plusSeconds(amountToAdd);
case MINUTES: return plusMinutes(amountToAdd);
case HOURS: return plusHours(amountToAdd);
case HALF_DAYS: return plusDays(amountToAdd / 256).plusHours((amountToAdd % 256) * 12); // no overflow (256 is multiple of 2)
代码示例来源:origin: Ullink/simple-slack-api
@Override
public List<SlackMessagePosted> fetchHistoryOfChannel(String channelId, LocalDate day, int numberOfMessages, Set<String> allowedSubtypes) {
Map<String, String> params = new HashMap<>();
params.put("channel", channelId);
if (day != null) {
ZonedDateTime start = ZonedDateTime.of(day.atStartOfDay(), ZoneId.of("UTC"));
ZonedDateTime end = ZonedDateTime.of(day.atStartOfDay().plusDays(1).minus(1, ChronoUnit.MILLIS), ZoneId.of("UTC"));
params.put("oldest", convertDateToSlackTimestamp(start));
params.put("latest", convertDateToSlackTimestamp(end));
}
if (numberOfMessages > -1) {
params.put("count", String.valueOf(numberOfMessages));
} else {
params.put("count", String.valueOf(DEFAULT_HISTORY_FETCH_SIZE));
}
SlackChannel channel = session.findChannelById(channelId);
switch (channel.getType()) {
case INSTANT_MESSAGING:
return fetchHistoryOfChannel(params,FETCH_IM_HISTORY_COMMAND, allowedSubtypes);
case PRIVATE_GROUP:
return fetchHistoryOfChannel(params,FETCH_GROUP_HISTORY_COMMAND, allowedSubtypes);
default:
return fetchHistoryOfChannel(params,FETCH_CHANNEL_HISTORY_COMMAND, allowedSubtypes);
}
}
代码示例来源:origin: ThreeTen/threetenbp
LocalDateTime ldt = LocalDateTime.of(year, month, day, hour, min, sec, 0).plusDays(days);
instantSecs = ldt.toEpochSecond(ZoneOffset.UTC);
instantSecs += Jdk8Methods.safeMultiply(yearParsed / 10000L, SECONDS_PER_10000_YEARS);
代码示例来源:origin: org.threeten/threetenbp
LocalDateTime ldt = LocalDateTime.of(year, month, day, hour, min, sec, 0).plusDays(days);
instantSecs = ldt.toEpochSecond(ZoneOffset.UTC);
instantSecs += Jdk8Methods.safeMultiply(yearParsed / 10000L, SECONDS_PER_10000_YEARS);
内容来源于网络,如有侵权,请联系作者删除!