java.time.LocalDateTime.plusNanos()方法的使用及代码示例

x33g5p2x  于2022-01-23 转载在 其他  
字(3.9k)|赞(0)|评价(0)|浏览(200)

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

LocalDateTime.plusNanos介绍

[英]Returns a copy of this LocalDateTime with the specified period in nanoseconds added.

This instance is immutable and unaffected by this method call.
[中]返回此LocalDateTime的副本,并添加指定的时间段(以纳秒为单位)。
此实例是不可变的,不受此方法调用的影响。

代码示例

代码示例来源:origin: SeanDragon/protools

public DatePlus addNano(long nanoSeconds) {
  this.localDateTime = this.localDateTime.plusNanos(nanoSeconds);
  return this;
}
//endregion

代码示例来源:origin: com.liumapp.qtools.date/qtools-date

public DatePlus addNano(long nanoSeconds) {
  this.localDateTime = this.localDateTime.plusNanos(nanoSeconds);
  return this;
}
//endregion

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

/**
 * Returns a copy of this {@code OffsetDateTime} with the specified period in nanoseconds added.
 * <p>
 * This instance is immutable and unaffected by this method call.
 *
 * @param nanos  the nanos to add, may be negative
 * @return an {@code OffsetDateTime} based on this date-time with the nanoseconds added, not null
 * @throws DateTimeException if the unit cannot be added to this type
 */
public OffsetDateTime plusNanos(long nanos) {
  return with(dateTime.plusNanos(nanos), offset);
}

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

/**
 * Returns a copy of this {@code ZonedDateTime} with the specified period in nanoseconds added.
 * <p>
 * This operates on the instant time-line, such that adding one nano will
 * always be a duration of one nano later.
 * This may cause the local date-time to change by an amount other than one nano.
 * Note that this is a different approach to that used by days, months and years.
 * <p>
 * This instance is immutable and unaffected by this method call.
 *
 * @param nanos  the nanos to add, may be negative
 * @return a {@code ZonedDateTime} based on this date-time with the nanoseconds added, not null
 * @throws DateTimeException if the result exceeds the supported date range
 */
public ZonedDateTime plusNanos(long nanos) {
  return resolveInstant(dateTime.plusNanos(nanos));
}

代码示例来源:origin: nl.psek.fitnesse/psek-fitnesse-fixtures-general

/**
 * Returns the supplied time plus a number of Millis in the specified output format.
 *
 * @param numberOfMillis the number of Millis in the future based on the supplied time.
 * @return the time.
 */
public String giveTimestampPlusNumberOfMillis(String time, int numberOfMillis, String dateFormat) {
  return getTime(time, dateFormat).plusNanos((long)numberOfMillis* 1000000).format(getFormat(dateFormat));
}

代码示例来源:origin: ivannp/tradelib

transaction.ts = transaction.ts.plusNanos(1000);
transaction.quantity += ppq;
ppq = 0;

代码示例来源:origin: marschall/threeten-jpa

static OffsetDateTime timestampWithTimeZoneToOffsetDateTime(TimestampWithTimeZone dbData) {
 if (dbData == null) {
  return null;
 }
 long dateValue = dbData.getYMD();
 int year = DateTimeUtils.yearFromDateValue(dateValue);
 int month = DateTimeUtils.monthFromDateValue(dateValue);
 int day = DateTimeUtils.dayFromDateValue(dateValue);
 LocalDate localDate = LocalDate.of(year, month, day);
 long timeNanos = dbData.getNanosSinceMidnight();
 LocalDateTime localDateTime = localDate.atStartOfDay().plusNanos(timeNanos);
 short timeZoneOffsetMins = dbData.getTimeZoneOffsetMins();
 int offsetSeconds = Math.toIntExact(MINUTES.toSeconds(timeZoneOffsetMins));
 ZoneOffset offset = ZoneOffset.ofTotalSeconds(offsetSeconds);
 return OffsetDateTime.of(localDateTime, offset);
}

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

ChronoUnit f = (ChronoUnit) unit;
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);

代码示例来源:origin: vmware/admiral

callbackState.due = LocalDateTime.now().plusNanos(stagePhaseTimeout.toNanos());

代码示例来源:origin: ivannp/tradelib

if(of != null) {
 ldt = ldt.plusNanos(1000);

代码示例来源:origin: dbs-leipzig/gradoop

create(DATETIME_VAL_d),
 create(DATETIME_VAL_d),
 create(DATETIME_VAL_d.plusNanos(1L))
);

相关文章

LocalDateTime类方法