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


Java Clock.tick方法代码示例

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


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

示例1: test__equals

import java.time.Clock; //导入方法依赖的package包/类
public void test__equals() {
    Clock a = Clock.tick(Clock.system(PARIS), Duration.ofMillis(500));
    Clock b = Clock.tick(Clock.system(PARIS), Duration.ofMillis(500));
    assertEquals(a.equals(a), true);
    assertEquals(a.equals(b), true);
    assertEquals(b.equals(a), true);
    assertEquals(b.equals(b), true);

    Clock c = Clock.tick(Clock.system(MOSCOW), Duration.ofMillis(500));
    assertEquals(a.equals(c), false);

    Clock d = Clock.tick(Clock.system(PARIS), Duration.ofMillis(499));
    assertEquals(a.equals(d), false);

    assertEquals(a.equals(null), false);
    assertEquals(a.equals("other type"), false);
    assertEquals(a.equals(Clock.systemUTC()), false);
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:19,代码来源:TCKClock_Tick.java

示例2: test_hashCode

import java.time.Clock; //导入方法依赖的package包/类
public void test_hashCode() {
    Clock a = Clock.tick(Clock.system(PARIS), Duration.ofMillis(500));
    Clock b = Clock.tick(Clock.system(PARIS), Duration.ofMillis(500));
    assertEquals(a.hashCode(), a.hashCode());
    assertEquals(a.hashCode(), b.hashCode());

    Clock c = Clock.tick(Clock.system(MOSCOW), Duration.ofMillis(500));
    assertEquals(a.hashCode() == c.hashCode(), false);

    Clock d = Clock.tick(Clock.system(PARIS), Duration.ofMillis(499));
    assertEquals(a.hashCode() == d.hashCode(), false);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:13,代码来源:TCKClock_Tick.java

示例3: test_tick_ClockDuration_subMilliNotDivisible_123ns

import java.time.Clock; //导入方法依赖的package包/类
@Test(expectedExceptions = IllegalArgumentException.class)
public void test_tick_ClockDuration_subMilliNotDivisible_123ns() {
    Clock.tick(Clock.systemUTC(), Duration.ofSeconds(0, 123));
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:5,代码来源:TCKClock_Tick.java

示例4: test_tick_ClockDuration_zeroDuration

import java.time.Clock; //导入方法依赖的package包/类
public void test_tick_ClockDuration_zeroDuration() {
    Clock underlying = Clock.system(PARIS);
    Clock test = Clock.tick(underlying, Duration.ZERO);
    assertSame(test, underlying);  // spec says same
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:6,代码来源:TCKClock_Tick.java

示例5: test_tick_ClockDuration_1nsDuration

import java.time.Clock; //导入方法依赖的package包/类
public void test_tick_ClockDuration_1nsDuration() {
    Clock underlying = Clock.system(PARIS);
    Clock test = Clock.tick(underlying, Duration.ofNanos(1));
    assertSame(test, underlying);  // spec says same
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:6,代码来源:TCKClock_Tick.java

示例6: test_tick_ClockDuration_maxDuration

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

示例7: test_tick_ClockDuration_subMilliNotDivisible_999ns

import java.time.Clock; //导入方法依赖的package包/类
@Test(expectedExceptions = IllegalArgumentException.class)
public void test_tick_ClockDuration_subMilliNotDivisible_999ns() {
    Clock.tick(Clock.systemUTC(), Duration.ofSeconds(0, 999));
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:5,代码来源:TCKClock_Tick.java

示例8: test_tick_ClockDuration_negative1ns

import java.time.Clock; //导入方法依赖的package包/类
@Test(expectedExceptions = IllegalArgumentException.class)
public void test_tick_ClockDuration_negative1ns() {
    Clock.tick(Clock.systemUTC(), Duration.ofSeconds(0, -1));
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:5,代码来源:TCKClock_Tick.java

示例9: test_withZone

import java.time.Clock; //导入方法依赖的package包/类
public void test_withZone() {
    Clock test = Clock.tick(Clock.system(PARIS), Duration.ofMillis(500));
    Clock changed = test.withZone(MOSCOW);
    assertEquals(test.getZone(), PARIS);
    assertEquals(changed.getZone(), MOSCOW);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:7,代码来源:TCKClock_Tick.java

示例10: test_tick_ClockDuration_nullClock

import java.time.Clock; //导入方法依赖的package包/类
@Test(expectedExceptions = NullPointerException.class)
public void test_tick_ClockDuration_nullClock() {
    Clock.tick(null, Duration.ZERO);
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:5,代码来源:TCKClock_Tick.java

示例11: test_tick_ClockDuration_negative1s

import java.time.Clock; //导入方法依赖的package包/类
@Test(expectedExceptions = IllegalArgumentException.class)
public void test_tick_ClockDuration_negative1s() {
    Clock.tick(Clock.systemUTC(), Duration.ofSeconds(-1));
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:5,代码来源:TCKClock_Tick.java

示例12: test_withZone_equal

import java.time.Clock; //导入方法依赖的package包/类
public void test_withZone_equal() {
    Clock test = Clock.tick(Clock.system(PARIS), Duration.ofMillis(500));
    Clock changed = test.withZone(PARIS);
    assertEquals(test, changed);
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:6,代码来源:TCKClock_Tick.java

示例13: test_withZone_same

import java.time.Clock; //导入方法依赖的package包/类
public void test_withZone_same() {
    Clock test = Clock.tick(Clock.system(PARIS), Duration.ofMillis(500));
    Clock changed = test.withZone(PARIS);
    assertSame(test, changed);
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:6,代码来源:TestClock_Tick.java


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