当前位置: 首页>>代码示例>>Java>>正文


Java Duration.ZERO属性代码示例

本文整理汇总了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);
}
 
开发者ID:orekyuu,项目名称:Riho,代码行数:26,代码来源:MojaRenderer.java

示例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;
    };
}
 
开发者ID:Microsoft,项目名称:elastic-db-tools-for-java,代码行数:23,代码来源:ExponentialBackoff.java

示例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;
}
 
开发者ID:chatbot-workshop,项目名称:java-messenger-watchdog,代码行数:18,代码来源:HttpTestService.java

示例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);
}
 
开发者ID:BFergerson,项目名称:Chronetic,代码行数:11,代码来源:ChronoFitness.java

示例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());
}
 
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:11,代码来源:Match.java

示例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;
    }
}
 
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:10,代码来源:Post.java

示例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();
}
 
开发者ID:Bandwidth,项目名称:async-sqs,代码行数:7,代码来源:TimeWindowAverageTest.java

示例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);
    }
}
 
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:11,代码来源:PunchClock.java

示例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);
}
 
开发者ID:Mercateo,项目名称:sqs-utils,代码行数:13,代码来源:LongRunningMessageHandlerIntegrationTest.java

示例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);
}
 
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:15,代码来源:ServerFormatter.java

示例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);
}
 
开发者ID:papyrusglobal,项目名称:state-channels,代码行数:35,代码来源:DurationConverter.java

示例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);
}
 
开发者ID:Bandwidth,项目名称:async-sqs,代码行数:7,代码来源:TimeWindowAverageTest.java

示例13: getUptimeAsDuration

public static final Duration getUptimeAsDuration(Instant timestamp) {
    if (timestamp == null) {
        return Duration.ZERO;
    }
    return Duration.between(Standard.getStarted(), timestamp);
}
 
开发者ID:Panzer1119,项目名称:Supreme-Bot,代码行数:6,代码来源:Util.java

示例14: DebouncedTask

DebouncedTask(Scheduler scheduler, Runnable runnable) {
    this(scheduler, Duration.ZERO, runnable);
}
 
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:3,代码来源:DebouncedTask.java

示例15: totalBlockingTime

default Duration totalBlockingTime() {
    return Duration.ZERO;
}
 
开发者ID:agroal,项目名称:agroal,代码行数:3,代码来源:AgroalDataSourceMetrics.java


注:本文中的java.time.Duration.ZERO属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。