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());
}
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);
}
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);
}
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);
}
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);
}
Aggregations