Search in sources :

Example 26 with Clock

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

the class TCKClock_System method test_systemDefaultZone.

public void test_systemDefaultZone() {
    Clock test = Clock.systemDefaultZone();
    assertEquals(test.getZone(), ZoneId.systemDefault());
    assertEquals(test, Clock.system(ZoneId.systemDefault()));
}
Also used : Clock(java.time.Clock)

Example 27 with Clock

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

the class TCKClock_System method test_hashCode.

public void test_hashCode() {
    Clock a = Clock.system(ZoneOffset.UTC);
    Clock b = Clock.system(ZoneOffset.UTC);
    assertEquals(a.hashCode(), a.hashCode());
    assertEquals(a.hashCode(), b.hashCode());
    Clock c = Clock.system(PARIS);
    assertEquals(a.hashCode() == c.hashCode(), false);
}
Also used : Clock(java.time.Clock)

Example 28 with Clock

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

the class TCKClock_System method test_instant.

//-----------------------------------------------------------------------
public void test_instant() {
    Clock system = Clock.systemUTC();
    assertEquals(system.getZone(), ZoneOffset.UTC);
    for (int i = 0; i < 10000; i++) {
        // assume can eventually get these within 10 milliseconds
        Instant instant = system.instant();
        long systemMillis = System.currentTimeMillis();
        if (systemMillis - instant.toEpochMilli() < 10) {
            // success
            return;
        }
    }
    fail();
}
Also used : Instant(java.time.Instant) Clock(java.time.Clock)

Example 29 with Clock

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

the class TCKClock_System method test_systemUTC.

//-------------------------------------------------------------------------
public void test_systemUTC() {
    Clock test = Clock.systemUTC();
    assertEquals(test.getZone(), ZoneOffset.UTC);
    assertEquals(test, Clock.system(ZoneOffset.UTC));
}
Also used : Clock(java.time.Clock)

Example 30 with Clock

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

the class TCKClock_System method test_withZone.

//-------------------------------------------------------------------------
public void test_withZone() {
    Clock test = Clock.system(PARIS);
    Clock changed = test.withZone(MOSCOW);
    assertEquals(test.getZone(), PARIS);
    assertEquals(changed.getZone(), MOSCOW);
}
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