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