Search in sources :

Example 71 with Clock

use of java.time.Clock in project j2objc by google.

the class TCKInstant method now_Clock_allSecsInDay_utc.

@Test
public void now_Clock_allSecsInDay_utc() {
    for (int i = 0; i < (2 * 24 * 60 * 60); i++) {
        Instant expected = Instant.ofEpochSecond(i).plusNanos(123456789L);
        Clock clock = Clock.fixed(expected, ZoneOffset.UTC);
        Instant test = Instant.now(clock);
        assertEquals(test, expected);
    }
}
Also used : Instant(java.time.Instant) Clock(java.time.Clock) Test(org.junit.Test)

Example 72 with Clock

use of java.time.Clock in project j2objc by google.

the class TCKClock_Tick method test_tick_ClockDuration_1nsDuration.

public void test_tick_ClockDuration_1nsDuration() {
    Clock underlying = Clock.system(PARIS);
    Clock test = Clock.tick(underlying, Duration.ofNanos(1));
    // spec says same
    assertSame(test, underlying);
}
Also used : Clock(java.time.Clock)

Example 73 with Clock

use of java.time.Clock in project j2objc by google.

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 74 with Clock

use of java.time.Clock in project j2objc by google.

the class TCKClock_Tick method test_tick_ClockDuration_250millis.

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

Example 75 with Clock

use of java.time.Clock in project j2objc by google.

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)

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