本文整理了Java中io.opencensus.common.Timestamp.compareTo()
方法的一些代码示例,展示了Timestamp.compareTo()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Timestamp.compareTo()
方法的具体详情如下:
包路径:io.opencensus.common.Timestamp
类名称:Timestamp
方法名:compareTo
[英]Compares this Timestamp to the specified Timestamp.
[中]将此时间戳与指定的时间戳进行比较。
代码示例来源:origin: census-instrumentation/opencensus-java
/**
* Constructs a new {@link CumulativeData}.
*
* @since 0.8
*/
public static CumulativeData create(Timestamp start, Timestamp end) {
if (start.compareTo(end) > 0) {
throw new IllegalArgumentException("Start time is later than end time.");
}
return new AutoValue_ViewData_AggregationWindowData_CumulativeData(start, end);
}
}
代码示例来源:origin: com.impetus.fabric/fabric-jdbc-driver-shaded
/** Constructs a new {@link CumulativeData}. */
public static CumulativeData create(Timestamp start, Timestamp end) {
if (start.compareTo(end) > 0) {
throw new IllegalArgumentException("Start time is later than end time.");
}
return new AutoValue_ViewData_AggregationWindowData_CumulativeData(start, end);
}
}
代码示例来源:origin: census-instrumentation/opencensus-java
@Override
public int compare(TimedEvent<?> o1, TimedEvent<?> o2) {
return o1.getTimestamp().compareTo(o2.getTimestamp());
}
}
代码示例来源:origin: census-instrumentation/opencensus-java
@Override
public int compare(SpanData o1, SpanData o2) {
return incremental
? o1.getStartTimestamp().compareTo(o2.getStartTimestamp())
: o2.getStartTimestamp().compareTo(o1.getStartTimestamp());
}
}
代码示例来源:origin: census-instrumentation/opencensus-java
private void refreshBucketList(Timestamp now) {
if (buckets.size() != N + 1) {
throw new AssertionError("Bucket list must have exactly " + (N + 1) + " buckets.");
}
Timestamp startOfLastBucket =
CheckerFrameworkUtils.castNonNull(buckets.peekLast()).getStart();
// TODO(songya): decide what to do when time goes backwards
checkArgument(
now.compareTo(startOfLastBucket) >= 0,
"Current time must be within or after the last bucket.");
long elapsedTimeMillis = now.subtractTimestamp(startOfLastBucket).toMillis();
long numOfPadBuckets = elapsedTimeMillis / bucketDuration.toMillis();
shiftBucketList(numOfPadBuckets, now);
}
代码示例来源:origin: io.opencensus/opencensus-impl-core
private void refreshBucketList(Timestamp now) {
if (buckets.size() != N + 1) {
throw new AssertionError("Bucket list must have exactly " + (N + 1) + " buckets.");
}
Timestamp startOfLastBucket =
CheckerFrameworkUtils.castNonNull(buckets.peekLast()).getStart();
// TODO(songya): decide what to do when time goes backwards
checkArgument(
now.compareTo(startOfLastBucket) >= 0,
"Current time must be within or after the last bucket.");
long elapsedTimeMillis = now.subtractTimestamp(startOfLastBucket).toMillis();
long numOfPadBuckets = elapsedTimeMillis / bucketDuration.toMillis();
shiftBucketList(numOfPadBuckets, now);
}
代码示例来源:origin: census-instrumentation/opencensus-java
@Test
public void timestamp_CompareTo() {
assertThat(Timestamp.create(0, 0).compareTo(Timestamp.create(0, 0))).isEqualTo(0);
assertThat(Timestamp.create(24, 42).compareTo(Timestamp.create(24, 42))).isEqualTo(0);
assertThat(Timestamp.create(-24, 42).compareTo(Timestamp.create(-24, 42))).isEqualTo(0);
assertThat(Timestamp.create(25, 42).compareTo(Timestamp.create(24, 42))).isEqualTo(1);
assertThat(Timestamp.create(24, 45).compareTo(Timestamp.create(24, 42))).isEqualTo(1);
assertThat(Timestamp.create(24, 42).compareTo(Timestamp.create(25, 42))).isEqualTo(-1);
assertThat(Timestamp.create(24, 42).compareTo(Timestamp.create(24, 45))).isEqualTo(-1);
assertThat(Timestamp.create(-25, 42).compareTo(Timestamp.create(-24, 42))).isEqualTo(-1);
assertThat(Timestamp.create(-24, 45).compareTo(Timestamp.create(-24, 42))).isEqualTo(1);
assertThat(Timestamp.create(-24, 42).compareTo(Timestamp.create(-25, 42))).isEqualTo(1);
assertThat(Timestamp.create(-24, 42).compareTo(Timestamp.create(-24, 45))).isEqualTo(-1);
}
内容来源于网络,如有侵权,请联系作者删除!