當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。