本文整理汇总了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));
}
}
示例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);
}
示例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));
}
}
示例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 },
};
}
示例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},
};
}
示例6: AggregatorBuilder
import java.time.Duration; //导入方法依赖的package包/类
public AggregatorBuilder() {
this.window = Duration.ofMinutes(10);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例12: getDuration
import java.time.Duration; //导入方法依赖的package包/类
@Override
public Duration getDuration() {
return Duration.ofMinutes(90);
}
示例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);
}
示例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);
}
示例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);
}