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

x33g5p2x  于2022-01-17 转载在 其他  
字(4.4k)|赞(0)|评价(0)|浏览(152)

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

Duration.plusNanos介绍

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

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

代码示例

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

.plusMinutes(minutes)
.plusSeconds(seconds)
.plusNanos(nanoSeconds);

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

.plusMinutes(interval.getMinutes())
      .plusSeconds(secondsLong)
      .plusNanos(nanos);
});

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

nanoSeconds = deserializeFractionalSecondsInNanos(meta, inputStream);
return Duration.ofHours(hours).plusMinutes(minutes).plusSeconds(seconds).plusNanos(nanoSeconds);

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

/**
 * Returns a copy of this duration with the specified duration in nanoseconds subtracted.
 * <p>
 * This instance is immutable and unaffected by this method call.
 *
 * @param nanosToSubtract  the nanoseconds to subtract, positive or negative
 * @return a {@code Duration} based on this duration with the specified nanoseconds subtracted, not null
 * @throws ArithmeticException if numeric overflow occurs
 */
public Duration minusNanos(long nanosToSubtract) {
  return (nanosToSubtract == Long.MIN_VALUE ? plusNanos(Long.MAX_VALUE).plusNanos(1) : plusNanos(-nanosToSubtract));
}

代码示例来源:origin: com.github.lgooddatepicker/LGoodDatePicker

fractionalPartInNanos = fractionalPartInNanos.multiply(new BigDecimal(1000000000));
Duration result = Duration.ofSeconds(value.longValue());
result = result.plusNanos(fractionalPartInNanos.longValue());
return result;

代码示例来源:origin: org.jdbi/jdbi3-postgres

.plusMinutes(interval.getMinutes())
      .plusSeconds(secondsLong)
      .plusNanos(nanos);
});

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

case NANOS: return plusNanos(amountToAdd);
    case MICROS: return plusSeconds((amountToAdd / (1000000L * 1000)) * 1000).plusNanos((amountToAdd % (1000000L * 1000)) * 1000);
    case MILLIS: return plusMillis(amountToAdd);
    case SECONDS: return plusSeconds(amountToAdd);
return plusSeconds(duration.getSeconds()).plusNanos(duration.getNano());

代码示例来源:origin: com.github.lgooddatepicker/LGoodDatePicker

String s3 = convertStringFromDuration(Duration.ofSeconds(0), settings);
String s4 = convertStringFromDuration(Duration.ofSeconds(1), settings);
String s5 = convertStringFromDuration(Duration.ofSeconds(1).plusNanos(2), settings);
Duration m1 = convertStringToDuration("", settings);
Duration m2 = convertStringToDuration(" ", settings);
Duration m8 = convertStringToDuration("5.5d", settings);
Duration m9 = convertStringToDuration("5.5w", settings);
for (Duration duration = Duration.ofSeconds(0).plusNanos(0);
    duration.compareTo(Duration.ofDays(1000)) <= 0;
    duration = duration.plusHours(1)) {

代码示例来源:origin: com.github.marschall/threeten-jpa-oracle-impl

/**
 * Converts {@link INTERVALDS} to {@link Duration}.
 *
 * @param dbData the data from the database to be converted, possibly {@code null}
 * @return the converted value, possibly {@code null}
 */
public static Duration intervaldsToDuration(INTERVALDS dbData) {
 if (dbData == null) {
  return null;
 }
 byte[] bytes = dbData.toBytes();
 int day = toUnsignedInt(bytes[0]) << 24
     | toUnsignedInt(bytes[1]) << 16
     | toUnsignedInt(bytes[2]) << 8
     | toUnsignedInt(bytes[3]);
 day ^= HIGH_BIT_FLAG;
 int hour = toUnsignedInt(bytes[4]) - 60;
 int minute = toUnsignedInt(bytes[5]) - 60;
 int second = toUnsignedInt(bytes[6]) - 60;
 int nano = toUnsignedInt(bytes[7]) << 24
     | toUnsignedInt(bytes[8]) << 16
     | toUnsignedInt(bytes[9]) << 8
     | toUnsignedInt(bytes[10]);
 nano ^= HIGH_BIT_FLAG;
 return Duration.ofDays(day)
     .plusHours(hour)
     .plusMinutes(minute)
     .plusSeconds(second)
     .plusNanos(nano);
}

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

/**
 * Converts {@link INTERVALDS} to {@link Duration}.
 *
 * @param dbData the data from the database to be converted, possibly {@code null}
 * @return the converted value, possibly {@code null}
 */
public static Duration intervaldsToDuration(INTERVALDS dbData) {
 if (dbData == null) {
  return null;
 }
 byte[] bytes = dbData.toBytes();
 int day = toUnsignedInt(bytes[0]) << 24
     | toUnsignedInt(bytes[1]) << 16
     | toUnsignedInt(bytes[2]) << 8
     | toUnsignedInt(bytes[3]);
 day ^= HIGH_BIT_FLAG;
 int hour = toUnsignedInt(bytes[4]) - 60;
 int minute = toUnsignedInt(bytes[5]) - 60;
 int second = toUnsignedInt(bytes[6]) - 60;
 int nano = toUnsignedInt(bytes[7]) << 24
     | toUnsignedInt(bytes[8]) << 16
     | toUnsignedInt(bytes[9]) << 8
     | toUnsignedInt(bytes[10]);
 nano ^= HIGH_BIT_FLAG;
 return Duration.ofDays(day)
     .plusHours(hour)
     .plusMinutes(minute)
     .plusSeconds(second)
     .plusNanos(nano);
}

相关文章