本文整理了Java中io.opencensus.common.Timestamp.addDuration()
方法的一些代码示例,展示了Timestamp.addDuration()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Timestamp.addDuration()
方法的具体详情如下:
包路径:io.opencensus.common.Timestamp
类名称:Timestamp
方法名:addDuration
[英]Returns a Timestamp calculated as this Timestamp plus some Duration.
[中]返回一个时间戳,计算为该时间戳加上一些持续时间。
代码示例来源:origin: io.opencensus/opencensus-testing
/**
* Advances the time by a duration.
*
* @param duration the increase in time.
* @since 0.5
*/
public synchronized void advanceTime(Duration duration) {
currentTime = validateNanos(currentTime.addDuration(duration));
}
代码示例来源:origin: census-instrumentation/opencensus-java
/**
* Advances the time by a duration.
*
* @param duration the increase in time.
* @since 0.5
*/
public synchronized void advanceTime(Duration duration) {
currentTime = validateNanos(currentTime.addDuration(duration));
}
代码示例来源: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
private static Timestamp subtractDuration(Timestamp timestamp, Duration duration) {
return timestamp.addDuration(Duration.create(-duration.getSeconds(), -duration.getNanos()));
}
}
代码示例来源:origin: census-instrumentation/opencensus-java
CheckerFrameworkUtils.castNonNull(buckets.peekLast())
.getStart()
.addDuration(bucketDuration);
} else {
super.view.getAggregation(),
super.view.getMeasure()));
startOfNewBucket = startOfNewBucket.addDuration(bucketDuration);
代码示例来源: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: io.opencensus/opencensus-impl-core
CheckerFrameworkUtils.castNonNull(buckets.peekLast())
.getStart()
.addDuration(bucketDuration);
} else {
super.view.getAggregation(),
super.view.getMeasure()));
startOfNewBucket = startOfNewBucket.addDuration(bucketDuration);
代码示例来源:origin: census-instrumentation/opencensus-java
@Test
public void timestampAddDuration() {
Timestamp timestamp = Timestamp.create(1234, 223);
assertThat(timestamp.addDuration(Duration.create(1, 0))).isEqualTo(Timestamp.create(1235, 223));
assertThat(timestamp.addDuration(Duration.create(0, 1))).isEqualTo(Timestamp.create(1234, 224));
assertThat(timestamp.addDuration(Duration.create(1, 1))).isEqualTo(Timestamp.create(1235, 224));
assertThat(timestamp.addDuration(Duration.create(1, 999999900)))
.isEqualTo(Timestamp.create(1236, 123));
}
代码示例来源:origin: census-instrumentation/opencensus-java
@Test
public void timestampAddDuration_Negative() {
Timestamp timestamp = Timestamp.create(1234, 223);
assertThat(timestamp.addDuration(Duration.create(-1234, -223)))
.isEqualTo(Timestamp.create(0, 0));
assertThat(timestamp.addDuration(Duration.create(-1, 0)))
.isEqualTo(Timestamp.create(1233, 223));
assertThat(timestamp.addDuration(Duration.create(-1, -1)))
.isEqualTo(Timestamp.create(1233, 222));
assertThat(timestamp.addDuration(Duration.create(-1, -323)))
.isEqualTo(Timestamp.create(1232, 999999900));
assertThat(timestamp.addDuration(Duration.create(-33, -999999999)))
.isEqualTo(Timestamp.create(1200, 224));
}
内容来源于网络,如有侵权,请联系作者删除!