本文整理了Java中java.time.OffsetDateTime.plusDays()
方法的一些代码示例,展示了OffsetDateTime.plusDays()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。OffsetDateTime.plusDays()
方法的具体详情如下:
包路径:java.time.OffsetDateTime
类名称:OffsetDateTime
方法名:plusDays
[英]Returns a copy of this OffsetDateTime 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 the 2009-01-01.
This instance is immutable and unaffected by this method call.
[中]返回此OffsetDateTime的副本,并添加指定的期间(以天为单位)。
此方法将指定的金额添加到“天”字段中,根据需要增加“月”和“年”字段,以确保结果仍然有效。仅当超过最大/最小年份时,结果才无效。
例如,2008-12-31加上一天将导致2009-01-01。
此实例是不可变的,不受此方法调用的影响。
代码示例来源:origin: stackoverflow.com
public static final long nextDayStartSec(long epochSecondsInUTC) {
OffsetDateTime odt = Instant.ofEpochSecond(epochSecondsInUTC).atOffset(ZoneOffset.UTC);
return odt.plusDays(1).toEpochSecond();
}
代码示例来源:origin: com.github.seratch/java-time-backport
/**
* Returns a copy of this {@code OffsetDateTime} 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, 2008-12-31 minus 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 subtract, may be negative
* @return an {@code OffsetDateTime} based on this date-time with the days subtracted, not null
* @throws DateTimeException if the result exceeds the supported date range
*/
public OffsetDateTime minusDays(long days) {
return (days == Long.MIN_VALUE ? plusDays(Long.MAX_VALUE).plusDays(1) : plusDays(-days));
}
代码示例来源:origin: Netflix/iceberg
@Override
public Integer apply(Integer days) {
if (granularity == ChronoUnit.DAYS) {
return days;
}
return (int) granularity.between(EPOCH, EPOCH.plusDays(days));
}
代码示例来源:origin: Netflix/iceberg
static String humanDay(int dayOrdinal) {
OffsetDateTime day = EPOCH.plusDays(dayOrdinal);
return String.format("%04d-%02d-%02d",
day.getYear(), day.getMonth().getValue(), day.getDayOfMonth());
}
代码示例来源:origin: Netflix/iceberg
@Override
public String read(String reuse) {
OffsetDateTime day = EPOCH.plusDays(column.nextInteger());
return format("%04d-%02d-%02d", day.getYear(), day.getMonth().getValue(), day.getDayOfMonth());
}
}
代码示例来源:origin: Silverpeas/Silverpeas-Core
/**
* Creates a new period of time between the two non null specified dates. The period is spreading
* over all the day(s) between the specified inclusive start day and the exclusive end day; the
* period is expressed in days. For example, a period between 2016-12-15 and 2016-12-17 means the
* period is spreading over two days (2016-12-15 and 2016-12-16).
* @param startDay the start day of the period. It defines the inclusive date at which the
* period starts.
* @param endDay the end day of the period. It defines the exclusive date at which the period
* ends. The end date must be the same or after the start date. An end date equal to the start
* date means the period is spanning all the day of the start date; it is equivalent to an end
* date being one day after the start date.
* @return the period of days between the two specified dates.
*/
public static Period between(LocalDate startDay, LocalDate endDay) {
checkPeriod(startDay, endDay);
Period period = new Period();
period.startDateTime = startDay == LocalDate.MIN ? OffsetDateTime.MIN :
startDay.atStartOfDay(ZoneOffset.UTC).toOffsetDateTime();
period.endDateTime = endDay == LocalDate.MAX ? OffsetDateTime.MAX :
endDay.atStartOfDay(ZoneOffset.UTC).toOffsetDateTime();
if (startDay.isEqual(endDay)) {
period.endDateTime = period.endDateTime.plusDays(1);
}
period.inDays = true;
return period;
}
代码示例来源:origin: FundRequest/platform
private GithubIssueCommentsResult createCommentFromGithubUserMock(final long createdOfsetDays) {
return new GithubIssueCommentsResult(Math.abs(UUID.randomUUID().getMostSignificantBits()),
GithubUser.builder().login(githubUser).build(),
"hdfgjh",
OffsetDateTime.now().plusDays(createdOfsetDays),
OffsetDateTime.now().plusDays(createdOfsetDays),
"gdfhgjhhjlkj;lk");
}
}
代码示例来源:origin: org.n52.wps/engine
public StatusInfo getStatus() {
StatusInfo statusInfo = new StatusInfo();
statusInfo.setJobId(jobId);
this.lock.readLock().lock();
try {
statusInfo.setStatus(jobStatus);
if (jobStatus.equals(JobStatus.accepted()) || jobStatus.equals(JobStatus.running())) {
statusInfo.setEstimatedCompletion(estimatedCompletion);
statusInfo.setPercentCompleted(percentCompleted);
statusInfo.setNextPoll(nextPoll);
} else if (jobStatus.equals(JobStatus.succeeded()) || jobStatus.equals(JobStatus.failed())) {
//TODO use value from configuration
OffsetDateTime expirationDate = OffsetDateTime.now().plusDays(30);
statusInfo.setExpirationDate(expirationDate);
}
} finally {
this.lock.readLock().unlock();
}
return statusInfo;
}
代码示例来源:origin: org.openbase.bco/ontology.lib
/**
* Method adds/subtracts time from the current dateTime.
*
* @param minutes are the minutes.
* @param hours are the hours.
* @param days are the days.
* @param months are the months.
* @param years are the years.
* @return the changed dateTime as String.
*/
public static String addTimeToCurrentDateTime(final int minutes, final int hours, final int days, final int months, final int years) {
final OffsetDateTime now = OffsetDateTime.now();
now.plusMinutes(minutes);
now.plusHours(hours);
now.plusDays(days);
now.plusMonths(months);
now.plusYears(years);
return now.toString();
}
}
代码示例来源:origin: Silverpeas/Silverpeas-Core
final OffsetDateTime dateTime = (OffsetDateTime) startDate;
occStartDate = dateTime.minusDays(1).toLocalDate();
occEndDate = dateTime.plusDays(1).toLocalDate();
代码示例来源:origin: com.intuit.wasabi/wasabi-api
.minusDays(1).toLocalDate();
LocalDate afterExperimentDate = FilterUtil.parseUIDate(structuredFilter[2], timeZoneOffset)
.plusDays(1).toLocalDate();
return experimentLocalDate.isAfter(beforeExperimentDate)
&& experimentLocalDate.isBefore(afterExperimentDate);
代码示例来源:origin: RoboZonky/robozonky
@Test
void cleansOverThreshold() {
TenantState.of(SESSION_INFO).in(StateCleaner.class).update(m -> m.put("a", "b").put("b", "c"));
TenantState.of(SESSION_INFO).in(SessionInfo.class).update(m -> m.put("c", "d"));
final StateCleaner stateCleaner = new StateCleaner(OffsetDateTime.now().plusDays(1)); // delete everything
stateCleaner.accept(new MyTenant());
assertThat(TenantState.of(SESSION_INFO).in(StateCleaner.class).getLastUpdated()).isEmpty();
assertThat(TenantState.of(SESSION_INFO).in(SessionInfo.class).getLastUpdated()).isEmpty();
}
内容来源于网络,如有侵权,请联系作者删除!