Search in sources :

Example 31 with Clock

use of java.time.Clock in project jdk8u_jdk by JetBrains.

the class TCKClock_System method test_withZone_equal.

public void test_withZone_equal() {
    Clock test = Clock.system(PARIS);
    Clock changed = test.withZone(PARIS);
    assertEquals(changed.getZone(), PARIS);
}
Also used : Clock(java.time.Clock)

Example 32 with Clock

use of java.time.Clock in project jdk8u_jdk by JetBrains.

the class TCKClock_Tick method test_withZone_equal.

public void test_withZone_equal() {
    Clock test = Clock.tick(Clock.system(PARIS), Duration.ofMillis(500));
    Clock changed = test.withZone(PARIS);
    assertEquals(test, changed);
}
Also used : Clock(java.time.Clock)

Example 33 with Clock

use of java.time.Clock in project jdk8u_jdk by JetBrains.

the class TCKClock_Tick method test_tickMinutes_ZoneId.

//-----------------------------------------------------------------------
public void test_tickMinutes_ZoneId() {
    Clock test = Clock.tickMinutes(PARIS);
    assertEquals(test.getZone(), PARIS);
    Instant instant = test.instant();
    assertEquals(instant.getEpochSecond() % 60, 0);
    assertEquals(instant.getNano(), 0);
}
Also used : Instant(java.time.Instant) Clock(java.time.Clock)

Example 34 with Clock

use of java.time.Clock in project jdk8u_jdk by JetBrains.

the class TCKClock_Tick method test_tick_ClockDuration_250micros.

public void test_tick_ClockDuration_250micros() {
    for (int i = 0; i < 1000; i++) {
        Clock test = Clock.tick(Clock.fixed(ZDT.withNano(i * 1000).toInstant(), PARIS), Duration.ofNanos(250_000));
        assertEquals(test.instant(), ZDT.withNano((i / 250) * 250_000).toInstant());
        assertEquals(test.getZone(), PARIS);
    }
}
Also used : Clock(java.time.Clock)

Example 35 with Clock

use of java.time.Clock in project jdk8u_jdk by JetBrains.

the class TCKClock_Tick method test_hashCode.

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);
}
Also used : Clock(java.time.Clock)

Aggregations

Clock (java.time.Clock)209 Test (org.junit.Test)62 Instant (java.time.Instant)51 Test (org.testng.annotations.Test)43 LocalTime (java.time.LocalTime)15 ZonedDateTime (java.time.ZonedDateTime)12 LocalDateTime (java.time.LocalDateTime)11 ZoneId (java.time.ZoneId)11 LocalDate (java.time.LocalDate)10 OffsetDateTime (java.time.OffsetDateTime)8 Test (org.junit.jupiter.api.Test)7 HandlerTest (com.yahoo.vespa.config.server.http.HandlerTest)6 SessionHandlerTest (com.yahoo.vespa.config.server.http.SessionHandlerTest)6 IOException (java.io.IOException)6 SessionTest (com.yahoo.vespa.config.server.session.SessionTest)5 OffsetTime (java.time.OffsetTime)5 ZoneOffset (java.time.ZoneOffset)5 Chronology (java.time.chrono.Chronology)5 IsoChronology (java.time.chrono.IsoChronology)5 Date (java.util.Date)4