當前位置: 首頁>>代碼示例>>Java>>正文


Java Duration.ofMinutes方法代碼示例

本文整理匯總了Java中java.time.Duration.ofMinutes方法的典型用法代碼示例。如果您正苦於以下問題:Java Duration.ofMinutes方法的具體用法?Java Duration.ofMinutes怎麽用?Java Duration.ofMinutes使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在java.time.Duration的用法示例。


在下文中一共展示了Duration.ofMinutes方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: pick_task_should_delay_with_geometric_strategy

import java.time.Duration; //導入方法依賴的package包/類
@Test
public void pick_task_should_delay_with_geometric_strategy() {
    QueueLocation location = generateUniqueLocation();
    Duration expectedDelay;
    ZonedDateTime beforePickingTask;
    ZonedDateTime afterPickingTask;
    TaskRecord taskRecord;

    RetryTaskStrategy retryTaskStrategy = new RetryTaskStrategy.GeometricBackoff(
            QueueSettings.builder().withBetweenTaskTimeout(Duration.ZERO)
                    .withNoTaskTimeout(Duration.ZERO).build()
    );

    Long enqueueId = executeInTransaction(() -> queueDao.enqueue(location, new EnqueueParams<>()));

    for (int attempt = 1; attempt < 10; attempt++) {
        beforePickingTask = ZonedDateTime.now();
        taskRecord = resetProcessTimeAndPick(location, retryTaskStrategy, enqueueId);
        afterPickingTask = ZonedDateTime.now();
        expectedDelay = Duration.ofMinutes(BigInteger.valueOf(2L).pow(attempt - 1).longValue());
        Assert.assertThat(taskRecord.getAttemptsCount(), equalTo((long) attempt));
        Assert.assertThat(taskRecord.getProcessTime().isAfter(beforePickingTask.plus(expectedDelay.minus(WINDOWS_OS_DELAY))), equalTo(true));
        Assert.assertThat(taskRecord.getProcessTime().isBefore(afterPickingTask.plus(expectedDelay.plus(WINDOWS_OS_DELAY))), equalTo(true));
    }
}
 
開發者ID:yandex-money,項目名稱:db-queue,代碼行數:26,代碼來源:PickTaskDaoTest.java

示例2: scheduleMessage

import java.time.Duration; //導入方法依賴的package包/類
@Test
public void scheduleMessage() throws Exception {
    FutureTimepoint when = new FutureTimepoint(Duration.ofMinutes(1));
    long expectedSchedule = when.get().toMillis();
    long expectedCount = 1;
    PositiveN count = PositiveN.of(expectedCount);
    CountedSchedule metadata = new CountedSchedule(when, count);
    
    newTask().send(message(metadata, "msg"));
    
    verify(msgToQueue).putLongProperty(
            eq(Message.HDR_SCHEDULED_DELIVERY_TIME.toString()), 
            eq(expectedSchedule));
    verify(msgToQueue).putLongProperty(
            eq(MetaProps.ScheduleCountKey),
            eq(expectedCount));
    verify(producer).send(msgToQueue);
}
 
開發者ID:openmicroscopy,項目名稱:omero-ms-queue,代碼行數:19,代碼來源:CountedScheduleTaskTest.java

示例3: pick_task_should_delay_with_arithmetic_strategy

import java.time.Duration; //導入方法依賴的package包/類
@Test
public void pick_task_should_delay_with_arithmetic_strategy() {
    QueueLocation location = generateUniqueLocation();
    Duration expectedDelay;
    ZonedDateTime beforePickingTask;
    ZonedDateTime afterPickingTask;
    TaskRecord taskRecord;

    RetryTaskStrategy retryTaskStrategy = new RetryTaskStrategy.ArithmeticBackoff(
            QueueSettings.builder().withNoTaskTimeout(Duration.ZERO)
                    .withBetweenTaskTimeout(Duration.ZERO)
                    .build()
    );


    Long enqueueId = executeInTransaction(() -> queueDao.enqueue(location, new EnqueueParams<>()));

    for (int attempt = 1; attempt < 10; attempt++) {
        beforePickingTask = ZonedDateTime.now();
        taskRecord = resetProcessTimeAndPick(location, retryTaskStrategy, enqueueId);
        afterPickingTask = ZonedDateTime.now();
        expectedDelay = Duration.ofMinutes((long) (1 + (attempt - 1) * 2));
        Assert.assertThat(taskRecord.getAttemptsCount(), equalTo((long) attempt));
        Assert.assertThat(taskRecord.getProcessTime().isAfter(beforePickingTask.plus(expectedDelay.minus(WINDOWS_OS_DELAY))), equalTo(true));
        Assert.assertThat(taskRecord.getProcessTime().isBefore(afterPickingTask.plus(expectedDelay.plus(WINDOWS_OS_DELAY))), equalTo(true));
    }
}
 
開發者ID:yandex-money,項目名稱:db-queue,代碼行數:28,代碼來源:PickTaskDaoTest.java

示例4: localDateTimeRanges

import java.time.Duration; //導入方法依賴的package包/類
@DataProvider(name="localDateTimeRanges")
public Object[][] localDateTimeRanges() {
    return new Object[][] {
            { LocalDateTime.of(1990, 1, 1, 9, 0), LocalDateTime.of(1990, 12, 31, 13, 0), Duration.ofMinutes(1), false },
            { LocalDateTime.of(1990, 1, 1, 9, 0), LocalDateTime.of(1990, 12, 31, 15, 30), Duration.ofMinutes(5), false },
            { LocalDateTime.of(2014, 12, 1, 7 ,25), LocalDateTime.of(2013, 1, 1, 9, 15), Duration.ofMinutes(1), false },
            { LocalDateTime.of(2014, 12, 1, 6, 30), LocalDateTime.of(2014, 1, 1, 10, 45), Duration.ofMinutes(7), false },
            { LocalDateTime.of(1990, 1, 1, 9, 0), LocalDateTime.of(1990, 12, 31, 13, 0), Duration.ofMinutes(1), true },
            { LocalDateTime.of(1990, 1, 1, 9, 0), LocalDateTime.of(1990, 12, 31, 15, 30), Duration.ofMinutes(5), true },
            { LocalDateTime.of(2014, 12, 1, 7 ,25), LocalDateTime.of(2013, 1, 1, 9, 15), Duration.ofMinutes(1), true },
            { LocalDateTime.of(2014, 12, 1, 6, 30), LocalDateTime.of(2014, 1, 1, 10, 45), Duration.ofMinutes(7), true },
    };
}
 
開發者ID:zavtech,項目名稱:morpheus-core,代碼行數:14,代碼來源:RangeBasicTests.java

示例5: data_minus_TemporalAmount

import java.time.Duration; //導入方法依賴的package包/類
@DataProvider(name="minus_TemporalAmount")
Object[][] data_minus_TemporalAmount() {
    return new Object[][] {
        {YearMonth.of(1, 1), Period.ofYears(1), YearMonth.of(0, 1), null},
        {YearMonth.of(1, 1), Period.ofYears(-12), YearMonth.of(13, 1), null},
        {YearMonth.of(1, 1), Period.ofYears(0), YearMonth.of(1, 1), null},
        {YearMonth.of(999999999, 12), Period.ofYears(0), YearMonth.of(999999999, 12), null},
        {YearMonth.of(-999999999, 1), Period.ofYears(0), YearMonth.of(-999999999, 1), null},
        {YearMonth.of(0, 1), Period.ofYears(999999999), YearMonth.of(-999999999, 1), null},
        {YearMonth.of(0, 12), Period.ofYears(-999999999), YearMonth.of(999999999, 12), null},

        {YearMonth.of(1, 1), Period.ofMonths(1), YearMonth.of(0, 12), null},
        {YearMonth.of(1, 1), Period.ofMonths(-12), YearMonth.of(2, 1), null},
        {YearMonth.of(1, 1), Period.ofMonths(121), YearMonth.of(-10, 12), null},
        {YearMonth.of(1, 1), Period.ofMonths(0), YearMonth.of(1, 1), null},
        {YearMonth.of(999999999, 12), Period.ofMonths(0), YearMonth.of(999999999, 12), null},
        {YearMonth.of(-999999999, 1), Period.ofMonths(0), YearMonth.of(-999999999, 1), null},
        {YearMonth.of(-999999999, 2), Period.ofMonths(1), YearMonth.of(-999999999, 1), null},
        {YearMonth.of(999999999, 11), Period.ofMonths(-1), YearMonth.of(999999999, 12), null},

        {YearMonth.of(1, 1), Period.ofYears(1).withMonths(2), YearMonth.of(-1, 11), null},
        {YearMonth.of(1, 1), Period.ofYears(-12).withMonths(-1), YearMonth.of(13, 2), null},

        {YearMonth.of(1, 1), Period.ofMonths(2).withYears(1), YearMonth.of(-1, 11), null},
        {YearMonth.of(1, 1), Period.ofMonths(-1).withYears(-12), YearMonth.of(13, 2), null},

        {YearMonth.of(1, 1), Period.ofDays(365), null, DateTimeException.class},
        {YearMonth.of(1, 1), Duration.ofDays(365), null, DateTimeException.class},
        {YearMonth.of(1, 1), Duration.ofHours(365*24), null, DateTimeException.class},
        {YearMonth.of(1, 1), Duration.ofMinutes(365*24*60), null, DateTimeException.class},
        {YearMonth.of(1, 1), Duration.ofSeconds(365*24*3600), null, DateTimeException.class},
        {YearMonth.of(1, 1), Duration.ofNanos(365*24*3600*1000000000), null, DateTimeException.class},
    };
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:35,代碼來源:TCKYearMonth.java

示例6: AggregatorBuilder

import java.time.Duration; //導入方法依賴的package包/類
public AggregatorBuilder() {
    this.window = Duration.ofMinutes(10);
}
 
開發者ID:gilles-stragier,項目名稱:quickmon,代碼行數:4,代碼來源:AggregatorBuilder.java

示例7: mongoSessionConverter

import java.time.Duration; //導入方法依賴的package包/類
@Bean
public AbstractMongoSessionConverter mongoSessionConverter() {
	return new JdkMongoSessionConverter(Duration.ofMinutes(30));
}
 
開發者ID:spring-projects,項目名稱:spring-session-data-mongodb,代碼行數:5,代碼來源:MongoRepositoryJdkSerializationITest.java

示例8: getDuration

import java.time.Duration; //導入方法依賴的package包/類
@Override
protected Duration getDuration() {
    return Duration.ofMinutes(5);
}
 
開發者ID:after-the-sunrise,項目名稱:cryptotrader,代碼行數:5,代碼來源:VwapEstimator.java

示例9: factory_minutes

import java.time.Duration; //導入方法依賴的package包/類
@Test
public void factory_minutes() {
    Duration test = Duration.ofMinutes(2);
    assertEquals(test.getSeconds(), 120);
    assertEquals(test.getNano(), 0);
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:7,代碼來源:TCKDuration.java

示例10: factory_minutes_max

import java.time.Duration; //導入方法依賴的package包/類
@Test
public void factory_minutes_max() {
    Duration test = Duration.ofMinutes(Long.MAX_VALUE / 60);
    assertEquals(test.getSeconds(), (Long.MAX_VALUE / 60) * 60);
    assertEquals(test.getNano(), 0);
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:7,代碼來源:TCKDuration.java

示例11: step

import java.time.Duration; //導入方法依賴的package包/類
/**
 * Returns the step size (reporting frequency) to use. The default is 10 seconds.
 */
default Duration step() {
    String v = get(prefix() + ".step");
    return v == null ? Duration.ofMinutes(1) : Duration.parse(v);
}
 
開發者ID:micrometer-metrics,項目名稱:micrometer,代碼行數:8,代碼來源:SimpleConfig.java

示例12: getDuration

import java.time.Duration; //導入方法依賴的package包/類
@Override
public Duration getDuration() {
    return Duration.ofMinutes(90);
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:5,代碼來源:TCKDuration.java

示例13: minusMinutes_long

import java.time.Duration; //導入方法依賴的package包/類
@Test(dataProvider="MinusMinutes")
public void minusMinutes_long(long minutes, long amount, long expectedMinutes) {
    Duration t = Duration.ofMinutes(minutes);
    t = t.minusMinutes(amount);
    assertEquals(t.toMinutes(), expectedMinutes);
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:7,代碼來源:TCKDuration.java

示例14: step

import java.time.Duration; //導入方法依賴的package包/類
/**
 * Returns the step size to use in computing windowed statistics like max. The default is 1 minute.
 * To get the most out of these statistics, align the step interval to be close to your scrape interval.
 */
default Duration step() {
    String v = get(prefix() + ".step");
    return v == null ? Duration.ofMinutes(1) : Duration.parse(v);
}
 
開發者ID:micrometer-metrics,項目名稱:micrometer,代碼行數:9,代碼來源:StatsdConfig.java

示例15: minusMinutes_long_overflowTooSmall

import java.time.Duration; //導入方法依賴的package包/類
@Test(expectedExceptions = {ArithmeticException.class})
public void minusMinutes_long_overflowTooSmall() {
    Duration t = Duration.ofMinutes(Long.MIN_VALUE/60);
    t.minusMinutes(1);
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:6,代碼來源:TCKDuration.java


注:本文中的java.time.Duration.ofMinutes方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。