本文整理汇总了Java中java.time.Duration.ZERO属性的典型用法代码示例。如果您正苦于以下问题:Java Duration.ZERO属性的具体用法?Java Duration.ZERO怎么用?Java Duration.ZERO使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类java.time.Duration
的用法示例。
在下文中一共展示了Duration.ZERO属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: MojaRenderer
public MojaRenderer(Loop maxLoopCount) {
super(maxLoopCount);
emotionImage = ImageResources.emotionMojya();
ArrayList<KeyFrameAnimation.KeyFrame> animX = new ArrayList<>();
ArrayList<KeyFrameAnimation.KeyFrame> animY = new ArrayList<>();
Instant now = Instant.now();
double r = 1f / pos.length;
for (int i = 1; i < pos.length; i++) {
LinearAnimation x = new LinearAnimation(now, Duration.ZERO);
x.setFromValue(ImageUtil.defaultScale(pos[i - 1][0]));
x.setToValue(ImageUtil.defaultScale(pos[i][0]));
animX.add(new KeyFrameAnimation.KeyFrame(r * (i - 1), r * i, x));
LinearAnimation y = new LinearAnimation(now, Duration.ZERO);
y.setFromValue(ImageUtil.defaultScale(pos[i][1]));
y.setToValue(ImageUtil.defaultScale(pos[i - 1][1]));
animY.add(new KeyFrameAnimation.KeyFrame(r * (i - 1), r * i, y));
}
moveX = new KeyFrameAnimation(now, Duration.ofMillis(2000), animX);
moveY = new KeyFrameAnimation(now, Duration.ofMillis(2000), animY);
fade.setFromValue(1);
fade.setToValue(0);
}
示例2: getShouldRetry
/**
* Returns the corresponding ShouldRetry delegate.
*
* @return The ShouldRetry delegate.
*/
@Override
public ShouldRetry getShouldRetry() {
return (int currentRetryCount,
RuntimeException lastException,
ReferenceObjectHelper<Duration> refRetryInterval) -> {
if (currentRetryCount < this.retryCount) {
Double delta = this.deltaBackoff == Duration.ZERO ? 0.0
: (Math.pow(2.0, currentRetryCount) - 1) * ThreadLocalRandom.current().nextDouble((this.deltaBackoff.getSeconds() * 0.8),
(this.deltaBackoff.getSeconds() * 1.2));
Long interval = Math.min((this.minBackoff.getSeconds() + delta.intValue()), this.maxBackoff.getSeconds());
refRetryInterval.argValue = Duration.ofMillis(interval);
return true;
}
refRetryInterval.argValue = Duration.ZERO;
return false;
};
}
示例3: testWebsite
@Override
public TestResult testWebsite(Website website) {
TestResult testResult;
try {
HttpURLConnection con = (HttpURLConnection)website.url().openConnection();
con.setConnectTimeout(5000);
con.setReadTimeout(5000);
LocalDateTime startTime = LocalDateTime.now();
con.setRequestMethod("GET");
int responseCode = con.getResponseCode();
LocalDateTime endTime = LocalDateTime.now();
Duration responseTime = Duration.between(startTime, endTime);
testResult = new TestResult(LocalDateTime.now(), new HttpStatus(responseCode), responseTime);
} catch (IOException e) {
testResult = new TestResult(LocalDateTime.now(), new HttpStatus(0), Duration.ZERO);
}
return testResult;
}
示例4: ChronoFitness
private ChronoFitness(@NotNull Chronotype chronotype) {
this.chronotype = requireNonNull(chronotype);
this.validFitness = false;
this.chronosomeCount = 0;
this.chronoGeneCount = 0;
this.frequencyPrecision = Double.NaN;
this.patternAccuracy = Double.NaN;
this.patternInclusion = Double.NaN;
this.temporalInclusion = Duration.ZERO;
this.score = BigDecimal.valueOf(Double.MIN_VALUE);
}
示例5: runningTime
/**
* Get the duration of the match, or zero if the match has not started
*/
@Override
default Duration runningTime() {
Instant startTime = getStateChangeTime(MatchState.Running);
if(startTime == null) {
return Duration.ZERO;
}
return Duration.between(startTime, getEndTime());
}
示例6: getRespawnTime
@Override
public Duration getRespawnTime(double distance) {
if(respawnTime != null) {
return respawnTime;
} else if(respawnSpeed != null) {
return Duration.ofSeconds(Math.round(distance / respawnSpeed));
} else {
return Duration.ZERO;
}
}
示例7: testRemoveValues
@Test
public void testRemoveValues() {
TimeWindowAverage avg = new TimeWindowAverage(Duration.ZERO, MIN_COUNT_0);
avg.addData(0);
avg.addData(10);
assertThat(avg.getAverage()).isNaN();
}
示例8: getContinuousPresence
/**
* Time since the given key last punched in, or zero if the key has never punched in
*/
public Duration getContinuousPresence(T key) {
Duration inTime = inTimes.get(key);
if(inTime == null) {
return Duration.ZERO;
} else {
return getElapsed().minus(inTime);
}
}
示例9: setUp
@Before
public void setUp() throws Exception {
MockitoAnnotations.initMocks(this);
Map<String, String> attributes = new HashMap<>();
attributes.put("VisibilityTimeout", "10");
Queue queue = new Queue(new QueueName("queueName"), "queueUrl", attributes);
VisibilityTimeoutExtenderFactory timeoutExtenderFactory = new VisibilityTimeoutExtenderFactory(
sqsClient);
uut = new LongRunningMessageHandler<>(scheduledExecutorService, 4, 2,
messageHandlingRunnableFactory, timeoutExtenderFactory, worker, queue,
finishedMessageCallback, Duration.ofMillis(1), Duration.ZERO);
}
示例10: matchTime
public BaseComponent matchTime(MatchDoc doc) {
Duration time;
ChatColor color;
if(doc.start() == null) {
time = Duration.ZERO;
color = ChatColor.GOLD;
} else if(doc.end() == null) {
time = Duration.between(doc.start(), Instant.now());
color = ChatColor.GREEN;
} else {
time = Duration.between(doc.start(), doc.end());
color = ChatColor.GOLD;
}
return new Component(PeriodFormats.formatColons(time), color);
}
示例11: convert
@Override
public Duration convert(String source) {
source = source.trim();
if ("0".equals(source)) {
return Duration.ZERO;
}
Matcher matcher = pattern.matcher(source);
if (!matcher.matches()) throw new IllegalArgumentException("Illegal period: " + source);
long value = Long.parseLong(matcher.group(1));
switch (matcher.group(2).toLowerCase()) {
case "ns":
case "nanos":
return Duration.ofNanos(value);
case "ms":
case "msec":
case "millis":
return Duration.ofMillis(value);
case "s":
case "sec":
return Duration.ofSeconds(value);
case "m":
case "min":
return Duration.ofMinutes(value);
case "h":
case "hour":
case "hours":
return Duration.ofHours(value);
case "d":
case "day":
case "days":
return Duration.ofDays(value);
}
throw new IllegalArgumentException("Illegal unit: " + source);
}
示例12: testMinCount
@Test
public void testMinCount() {
TimeWindowAverage avg = new TimeWindowAverage(Duration.ZERO, MIN_COUNT_1);
avg.addData(0);
avg.addData(10);
assertThat(avg.getAverage()).isEqualTo(10.0);
}
示例13: getUptimeAsDuration
public static final Duration getUptimeAsDuration(Instant timestamp) {
if (timestamp == null) {
return Duration.ZERO;
}
return Duration.between(Standard.getStarted(), timestamp);
}
示例14: DebouncedTask
DebouncedTask(Scheduler scheduler, Runnable runnable) {
this(scheduler, Duration.ZERO, runnable);
}
示例15: totalBlockingTime
default Duration totalBlockingTime() {
return Duration.ZERO;
}