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


Java Duration.ofSeconds方法代码示例

本文整理汇总了Java中java.time.Duration.ofSeconds方法的典型用法代码示例。如果您正苦于以下问题:Java Duration.ofSeconds方法的具体用法?Java Duration.ofSeconds怎么用?Java Duration.ofSeconds使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.time.Duration的用法示例。


在下文中一共展示了Duration.ofSeconds方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: timeToDeleteFromEnter

import java.time.Duration; //导入方法依赖的package包/类
public static void timeToDeleteFromEnter() {
	timeFromEnterCategory = config.getCategory("timeFromEnter");
	timeFromEnterCategory.setComment("Time that has needed to pass since someone entered a chunk for it to be deleted");
	int years = config.getInt("years", "timeFromEnter", 0, 0, 100, "years that have needed to pass");
	int months = config.getInt("months", "timeFromEnter", 2, 0, 11, "months that have needed to pass");
	int days = config.getInt("days", "timeFromEnter", 0, 0, 30, "days that have needed to pass");
	int hours = config.getInt("hours", "timeFromEnter", 0, 0, 23, "hours that have needed to pass");
	int minutes = config.getInt("minutes", "timeFromEnter", 0, 0, 59, "minutes that have needed to pass");
	int seconds = config.getInt("seconds", "timeFromEnter", 0, 0, 59, "seconds that have needed to pass");
	timeFromEnter = Duration.ofSeconds(seconds);
	timeFromEnter = timeFromEnter.plusMinutes(minutes);
	timeFromEnter = timeFromEnter.plusHours(hours);
	timeFromEnter = timeFromEnter.plusDays(days);
	timeFromEnter = timeFromEnter.plusDays(months * 31);
	timeFromEnter = timeFromEnter.plusDays(Math.round(years * 365.25));
}
 
开发者ID:coehlrich,项目名称:chunk-logger,代码行数:17,代码来源:ChunkLoggerConfig.java

示例2: datadogStatsd

import java.time.Duration; //导入方法依赖的package包/类
public static StatsdMeterRegistry datadogStatsd() {
    return new StatsdMeterRegistry(new StatsdConfig() {
        @Override
        public Duration step() {
            return Duration.ofSeconds(10);
        }

        @Override
        public String get(String k) {
            return null;
        }

        @Override
        public StatsdFlavor flavor() {
            return StatsdFlavor.Datadog;
        }
    }, Clock.SYSTEM);
}
 
开发者ID:micrometer-metrics,项目名称:micrometer,代码行数:19,代码来源:SampleRegistries.java

示例3: reads_historic_events_from_a_stream_even_if_another_stream_runs_out_of_events

import java.time.Duration; //导入方法依赖的package包/类
@Test
public void reads_historic_events_from_a_stream_even_if_another_stream_runs_out_of_events() {
    Iterator<EventInIdentifiedStream> emptyStream = new SlowIterator<>(clock, Duration.ofSeconds(2), emptyIterator());
    List<EventInIdentifiedStream> stream2 = newArrayList(event(2, "2016-01-01T10:00:00Z", 2222L));

    clock.latchTo(Instant.parse("2016-01-01T10:00:00Z"));
    new EventStoreMergingIterator(clock, Duration.ofSeconds(0), of(emptyStream, stream2.iterator())).forEachRemaining(outputStream);
    assertThat(outputStream.eventVersions(), contains(2222L));

    outputStream.events.clear();

    clock.latchTo(Instant.parse("2016-01-01T10:00:00Z"));
    new EventStoreMergingIterator(clock, Duration.ofSeconds(0), of(stream2.iterator(), emptyStream)).forEachRemaining(outputStream);
    assertThat(outputStream.eventVersions(), contains(2222L));
}
 
开发者ID:tim-group,项目名称:tg-eventstore,代码行数:16,代码来源:EventStoreMergingIteratorTest.java

示例4: plusMillis_long_min

import java.time.Duration; //导入方法依赖的package包/类
@Test
public void plusMillis_long_min() {
    Duration t = Duration.ofSeconds(Long.MIN_VALUE, 1000000);
    t = t.plusMillis(-1);
    assertEquals(t.getSeconds(), Long.MIN_VALUE);
    assertEquals(t.getNano(), 0);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:8,代码来源:TCKDuration.java

示例5: only_reads_from_streams_up_to_the_time_any_stream_runs_out_of_events

import java.time.Duration; //导入方法依赖的package包/类
@Test
public void only_reads_from_streams_up_to_the_time_any_stream_runs_out_of_events() {
    Iterator<EventInIdentifiedStream> emptyStream = new SlowIterator<>(clock, Duration.ofSeconds(2), emptyIterator());
    List<EventInIdentifiedStream> stream2 = newArrayList(event(2, "2016-01-01T10:00:01Z", 2222L));

    clock.latchTo(Instant.parse("2016-01-01T10:00:00Z"));
    new EventStoreMergingIterator(clock, Duration.ofSeconds(0), of(emptyStream, stream2.iterator())).forEachRemaining(outputStream);
    assertThat(outputStream.eventVersions(), empty());

    clock.latchTo(Instant.parse("2016-01-01T10:00:00Z"));
    new EventStoreMergingIterator(clock, Duration.ofSeconds(0), of(stream2.iterator(), emptyStream)).forEachRemaining(outputStream);
    assertThat(outputStream.eventVersions(), empty());
}
 
开发者ID:tim-group,项目名称:tg-eventstore,代码行数:14,代码来源:EventStoreMergingIteratorTest.java

示例6: minusNanos_long

import java.time.Duration; //导入方法依赖的package包/类
@Test(dataProvider="MinusNanos")
public void minusNanos_long(long seconds, int nanos, long amount, long expectedSeconds, int expectedNanoOfSecond) {
    Duration t = Duration.ofSeconds(seconds, nanos);
    t = t.minusNanos(amount);
    assertEquals(t.getSeconds(), expectedSeconds);
    assertEquals(t.getNano(), expectedNanoOfSecond);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:8,代码来源:TCKDuration.java

示例7: parseDuration_ShouldReturnDurationOf_Seconds

import java.time.Duration; //导入方法依赖的package包/类
@Test
public void parseDuration_ShouldReturnDurationOf_Seconds() throws Exception {
    String raw = "00:00:05";

    Duration result = subject.parseDuration(raw);
    Duration expected = Duration.ofSeconds(5);

    assertThat(result).isEqualByComparingTo(expected);
}
 
开发者ID:ccremer,项目名称:clustercode,代码行数:10,代码来源:FfmpegParserTest.java

示例8: data_minusInvalidUnit

import java.time.Duration; //导入方法依赖的package包/类
@DataProvider(name="minusInvalidUnit")
Object[][] data_minusInvalidUnit() {
    return new Object[][] {
            {Period.of(0, 1, 0)},
            {Period.of(0, 0, 1)},
            {Period.of(0, 1, 1)},
            {Period.of(1, 1, 1)},
            {Duration.ofDays(1)},
            {Duration.ofHours(1)},
            {Duration.ofMinutes(1)},
            {Duration.ofSeconds(1)},
    };
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:14,代码来源:TCKYear.java

示例9: test_equals

import java.time.Duration; //导入方法依赖的package包/类
@Test
public void test_equals() {
    Duration test5a = Duration.ofSeconds(5L, 20);
    Duration test5b = Duration.ofSeconds(5L, 20);
    Duration test5n = Duration.ofSeconds(5L, 30);
    Duration test6 = Duration.ofSeconds(6L, 20);

    assertEquals(test5a.equals(test5a), true);
    assertEquals(test5a.equals(test5b), true);
    assertEquals(test5a.equals(test5n), false);
    assertEquals(test5a.equals(test6), false);

    assertEquals(test5b.equals(test5a), true);
    assertEquals(test5b.equals(test5b), true);
    assertEquals(test5b.equals(test5n), false);
    assertEquals(test5b.equals(test6), false);

    assertEquals(test5n.equals(test5a), false);
    assertEquals(test5n.equals(test5b), false);
    assertEquals(test5n.equals(test5n), true);
    assertEquals(test5n.equals(test6), false);

    assertEquals(test6.equals(test5a), false);
    assertEquals(test6.equals(test5b), false);
    assertEquals(test6.equals(test5n), false);
    assertEquals(test6.equals(test6), true);
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:28,代码来源:TCKDuration.java

示例10: test_toMillis_min

import java.time.Duration; //导入方法依赖的package包/类
@Test
public void test_toMillis_min() {
    Duration test = Duration.ofSeconds(Long.MIN_VALUE / 1000, (Long.MIN_VALUE % 1000) * 1000000);
    assertEquals(test.toMillis(), Long.MIN_VALUE);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:6,代码来源:TCKDuration.java

示例11: multipliedBy_tooBig

import java.time.Duration; //导入方法依赖的package包/类
@Test(expectedExceptions=ArithmeticException.class)
public void multipliedBy_tooBig() {
    Duration test = Duration.ofSeconds(1, 1);
    test.multipliedBy(Long.MAX_VALUE);
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:6,代码来源:TCKDuration.java

示例12: setup

import java.time.Duration; //导入方法依赖的package包/类
@Before
public void setup() {
    status = new EventSubscriptionStatus("", "", clock, DurationThreshold.warningThresholdWithCriticalRatio(Duration.ofSeconds(123), 1.25), new DurationThreshold(Duration.ofSeconds(1), Duration.ofSeconds(30)), new LocalEventSink());
    adapter = new SubscriptionListenerAdapter(new TestPosition(0), singletonList(status));
}
 
开发者ID:tim-group,项目名称:tg-eventstore,代码行数:6,代码来源:EventSubscriptionStatusTest.java

示例13: test_minus_Duration

import java.time.Duration; //导入方法依赖的package包/类
@Test
public void test_minus_Duration() {
    Duration dur = Duration.ofSeconds(62, 3);
    OffsetDateTime t = TEST_2008_6_30_11_30_59_000000500.minus(dur);
    assertEquals(t, OffsetDateTime.of(2008, 6, 30, 11, 29, 57, 497, OFFSET_PONE));
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:7,代码来源:TCKOffsetDateTime.java

示例14: plusSeconds_zeroReturnsThis

import java.time.Duration; //导入方法依赖的package包/类
@Test
public void plusSeconds_zeroReturnsThis() {
    Duration t = Duration.ofSeconds(-1);
    assertSame(t.plusSeconds(0), t);
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:6,代码来源:TestDuration.java

示例15: plusSeconds_long_overflowTooSmall

import java.time.Duration; //导入方法依赖的package包/类
@Test(expectedExceptions = {ArithmeticException.class})
public void plusSeconds_long_overflowTooSmall() {
    Duration t = Duration.ofSeconds(-1, 0);
    t.plusSeconds(Long.MIN_VALUE);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:6,代码来源:TCKDuration.java


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