use of java.time.LocalTime in project jdk8u_jdk by JetBrains.
the class TCKLocalTime method test_minusSeconds_one.
//-----------------------------------------------------------------------
// minusSeconds()
//-----------------------------------------------------------------------
@Test
public void test_minusSeconds_one() {
LocalTime t = LocalTime.MIDNIGHT;
int hour = 0;
int min = 0;
int sec = 0;
for (int i = 0; i < 3700; i++) {
t = t.minusSeconds(1);
sec--;
if (sec == -1) {
min--;
sec = 59;
if (min == -1) {
hour--;
min = 59;
if (hour == -1) {
hour = 23;
}
}
}
assertEquals(t.getHour(), hour);
assertEquals(t.getMinute(), min);
assertEquals(t.getSecond(), sec);
}
}
use of java.time.LocalTime in project jdk8u_jdk by JetBrains.
the class TCKLocalTime method test_withSecond_toMidday_equal.
@Test
public void test_withSecond_toMidday_equal() {
LocalTime t = LocalTime.of(12, 0, 1).withSecond(0);
assertEquals(t, LocalTime.NOON);
}
use of java.time.LocalTime in project jdk8u_jdk by JetBrains.
the class TCKLocalTime method test_until_invalidType.
@Test(expectedExceptions = DateTimeException.class)
public void test_until_invalidType() {
LocalTime start = LocalTime.of(11, 30);
start.until(LocalDate.of(2010, 6, 30), SECONDS);
}
use of java.time.LocalTime in project jdk8u_jdk by JetBrains.
the class TCKLocalTime method test_hashCode_hour_differs.
@Test(dataProvider = "sampleTimes")
public void test_hashCode_hour_differs(int h, int m, int s, int n) {
LocalTime a = LocalTime.of(h, m, s, n);
LocalTime b = LocalTime.of(h + 1, m, s, n);
assertEquals(a.hashCode() == b.hashCode(), false);
}
use of java.time.LocalTime in project jdk8u_jdk by JetBrains.
the class TCKLocalTime method now_ZoneId.
@Test
public void now_ZoneId() {
ZoneId zone = ZoneId.of("UTC+01:02:03");
LocalTime expected = LocalTime.now(Clock.system(zone));
LocalTime test = LocalTime.now(zone);
for (int i = 0; i < 100; i++) {
if (expected.equals(test)) {
return;
}
expected = LocalTime.now(Clock.system(zone));
test = LocalTime.now(zone);
}
assertEquals(test, expected);
}
Aggregations