io.opencensus.common.Duration.getSeconds()方法的使用及代码示例

x33g5p2x  于2022-01-18 转载在 其他  
字(4.5k)|赞(0)|评价(0)|浏览(135)

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

Duration.getSeconds介绍

[英]Returns the number of seconds in the Duration.
[中]返回持续时间内的秒数。

代码示例

代码示例来源:origin: census-instrumentation/opencensus-java

/**
 * Converts a {@link Duration} to milliseconds.
 *
 * @return the milliseconds representation of this {@code Duration}.
 * @since 0.13
 */
public long toMillis() {
 return TimeUnit.SECONDS.toMillis(getSeconds()) + TimeUnit.NANOSECONDS.toMillis(getNanos());
}

代码示例来源:origin: census-instrumentation/opencensus-java

private static double toDoubleSeconds(Duration duration) {
 return duration.getNanos() / NANOS_PER_SECOND + duration.getSeconds();
}

代码示例来源:origin: census-instrumentation/opencensus-java

private static long durationToNanos(Duration duration) {
 return TimeUnit.SECONDS.toNanos(duration.getSeconds()) + duration.getNanos();
}

代码示例来源:origin: census-instrumentation/opencensus-java

private static long toMillis(Timestamp start, Timestamp end) {
 Duration duration = end.subtractTimestamp(start);
 return SECONDS.toMillis(duration.getSeconds()) + NANOSECONDS.toMillis(duration.getNanos());
}

代码示例来源:origin: census-instrumentation/opencensus-java

/**
 * Returns a {@code Timestamp} calculated as this {@code Timestamp} plus some {@code Duration}.
 *
 * @param duration the {@code Duration} to add.
 * @return a {@code Timestamp} with the specified {@code Duration} added.
 * @since 0.5
 */
public Timestamp addDuration(Duration duration) {
 return plus(duration.getSeconds(), duration.getNanos());
}

代码示例来源:origin: com.impetus.fabric/fabric-jdbc-driver-shaded

/**
 * Returns a {@code Timestamp} calculated as this {@code Timestamp} plus some {@code Duration}.
 *
 * @param duration the {@code Duration} to add.
 * @return a {@code Timestamp} with the specified {@code Duration} added.
 */
public Timestamp addDuration(Duration duration) {
 return plus(duration.getSeconds(), duration.getNanos());
}

代码示例来源:origin: census-instrumentation/opencensus-java

/**
 * Compares this {@code Duration} to the specified {@code Duration}.
 *
 * @param otherDuration the other {@code Duration} to compare to, not {@code null}.
 * @return the comparator value: zero if equal, negative if this duration is smaller than
 *     otherDuration, positive if larger.
 * @throws NullPointerException if otherDuration is {@code null}.
 */
@Override
public int compareTo(Duration otherDuration) {
 int cmp = TimeUtils.compareLongs(getSeconds(), otherDuration.getSeconds());
 if (cmp != 0) {
  return cmp;
 }
 return TimeUtils.compareLongs(getNanos(), otherDuration.getNanos());
}

代码示例来源:origin: com.impetus.fabric/fabric-jdbc-driver-shaded

/**
 * Compares this {@code Duration} to the specified {@code Duration}.
 *
 * @param otherDuration the other {@code Duration} to compare to, not {@code null}.
 * @return the comparator value: zero if equal, negative if this duration is smaller than
 *     otherDuration, positive if larger.
 * @throws NullPointerException if otherDuration is {@code null}.
 */
@Override
public int compareTo(Duration otherDuration) {
 int cmp = Longs.compare(getSeconds(), otherDuration.getSeconds());
 if (cmp != 0) {
  return cmp;
 }
 return Longs.compare(getNanos(), otherDuration.getNanos());
}

代码示例来源:origin: census-instrumentation/opencensus-java

private static Timestamp subtractDuration(Timestamp timestamp, Duration duration) {
  return timestamp.addDuration(Duration.create(-duration.getSeconds(), -duration.getNanos()));
 }
}

代码示例来源:origin: io.opencensus/opencensus-impl-core

private static Timestamp subtractDuration(Timestamp timestamp, Duration duration) {
  return timestamp.addDuration(Duration.create(-duration.getSeconds(), -duration.getNanos()));
 }
}

代码示例来源:origin: census-instrumentation/opencensus-java

@Override
 public ViewData apply(ViewData.AggregationWindowData.IntervalData arg) {
  Duration duration = ((View.AggregationWindow.Interval) view.getWindow()).getDuration();
  return createInternal(
    view,
    Collections.unmodifiableMap(deepCopy),
    arg,
    arg.getEnd()
      .addDuration(Duration.create(-duration.getSeconds(), -duration.getNanos())),
    arg.getEnd());
 }
},

代码示例来源:origin: census-instrumentation/opencensus-java

@Test
public void testDurationCreate() {
 assertThat(Duration.create(24, 42).getSeconds()).isEqualTo(24);
 assertThat(Duration.create(24, 42).getNanos()).isEqualTo(42);
 assertThat(Duration.create(-24, -42).getSeconds()).isEqualTo(-24);
 assertThat(Duration.create(-24, -42).getNanos()).isEqualTo(-42);
 assertThat(Duration.create(315576000000L, 999999999).getSeconds()).isEqualTo(315576000000L);
 assertThat(Duration.create(315576000000L, 999999999).getNanos()).isEqualTo(999999999);
 assertThat(Duration.create(-315576000000L, -999999999).getSeconds()).isEqualTo(-315576000000L);
 assertThat(Duration.create(-315576000000L, -999999999).getNanos()).isEqualTo(-999999999);
}

相关文章