Search in sources :

Example 21 with Clock

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

the class TCKClock_Fixed method test_fixed_InstantZoneId.

//-------------------------------------------------------------------------
public void test_fixed_InstantZoneId() {
    Clock test = Clock.fixed(INSTANT, PARIS);
    assertEquals(test.instant(), INSTANT);
    assertEquals(test.getZone(), PARIS);
    assertEquals(test.instant().getEpochSecond() * 1000, test.millis());
}
Also used : Clock(java.time.Clock)

Example 22 with Clock

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

the class TCKClock_Fixed method test_equals.

//-----------------------------------------------------------------------
public void test_equals() {
    Clock a = Clock.fixed(INSTANT, ZoneOffset.UTC);
    Clock b = Clock.fixed(INSTANT, ZoneOffset.UTC);
    assertEquals(a.equals(a), true);
    assertEquals(a.equals(b), true);
    assertEquals(b.equals(a), true);
    assertEquals(b.equals(b), true);
    Clock c = Clock.fixed(INSTANT, PARIS);
    assertEquals(a.equals(c), false);
    Clock d = Clock.fixed(INSTANT.minusNanos(1), ZoneOffset.UTC);
    assertEquals(a.equals(d), false);
    assertEquals(a.equals(null), false);
    assertEquals(a.equals("other type"), false);
    assertEquals(a.equals(Clock.systemUTC()), false);
}
Also used : Clock(java.time.Clock)

Example 23 with Clock

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

the class TCKClock_Offset method test_offset_ClockDuration.

//-----------------------------------------------------------------------
public void test_offset_ClockDuration() {
    Clock test = Clock.offset(Clock.fixed(INSTANT, PARIS), OFFSET);
    //System.out.println(test.instant());
    //System.out.println(INSTANT.plus(OFFSET));
    assertEquals(test.instant(), INSTANT.plus(OFFSET));
    assertEquals(test.getZone(), PARIS);
}
Also used : Clock(java.time.Clock)

Example 24 with Clock

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

the class TCKClock_Offset method test_offset_ClockDuration_zeroDuration.

public void test_offset_ClockDuration_zeroDuration() {
    Clock underlying = Clock.system(PARIS);
    Clock test = Clock.offset(underlying, Duration.ZERO);
    // spec says same
    assertSame(test, underlying);
}
Also used : Clock(java.time.Clock)

Example 25 with Clock

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

the class TCKClock_Offset method test_withZone.

//-------------------------------------------------------------------------
public void test_withZone() {
    Clock test = Clock.offset(Clock.system(PARIS), OFFSET);
    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