use of java.time.LocalTime in project jdk8u_jdk by JetBrains.
the class TCKLocalTime method test_with_longTemporalField_amPmOfDay.
// Returns a {@code LocalTime} with the specified AM/PM.
// The hour-of-am-pm, minute-of-hour, second-of-minute and nano-of-second will be unchanged.
@Test
public void test_with_longTemporalField_amPmOfDay() {
for (int i = 0; i <= 1; i++) {
LocalTime test = TEST_12_30_40_987654321.with(AMPM_OF_DAY, i);
assertEquals(test.get(AMPM_OF_DAY), i);
assertEquals(test.get(HOUR_OF_AMPM), TEST_12_30_40_987654321.get(HOUR_OF_AMPM));
assertEquals(test.get(MINUTE_OF_HOUR), TEST_12_30_40_987654321.get(MINUTE_OF_HOUR));
assertEquals(test.get(SECOND_OF_MINUTE), TEST_12_30_40_987654321.get(SECOND_OF_MINUTE));
assertEquals(test.get(NANO_OF_SECOND), TEST_12_30_40_987654321.get(NANO_OF_SECOND));
}
}
use of java.time.LocalTime in project jdk8u_jdk by JetBrains.
the class TCKLocalTime method now_Clock_beforeEpoch.
@Test
public void now_Clock_beforeEpoch() {
for (int i = -1; i >= -(24 * 60 * 60); i--) {
Instant instant = Instant.ofEpochSecond(i, 8);
Clock clock = Clock.fixed(instant, ZoneOffset.UTC);
LocalTime test = LocalTime.now(clock);
assertEquals(test.getHour(), ((i + 24 * 60 * 60) / (60 * 60)) % 24);
assertEquals(test.getMinute(), ((i + 24 * 60 * 60) / 60) % 60);
assertEquals(test.getSecond(), (i + 24 * 60 * 60) % 60);
assertEquals(test.getNano(), 8);
}
}
use of java.time.LocalTime in project jdk8u_jdk by JetBrains.
the class TCKLocalTime method test_hashCode_second_differs.
@Test(dataProvider = "sampleTimes")
public void test_hashCode_second_differs(int h, int m, int s, int n) {
LocalTime a = LocalTime.of(h, m, s, n);
LocalTime b = LocalTime.of(h, m, s + 1, n);
assertEquals(a.hashCode() == b.hashCode(), false);
}
use of java.time.LocalTime in project jdk8u_jdk by JetBrains.
the class TCKOffsetDateTime method factory_of_LocalDateLocalTimeZoneOffset.
//-----------------------------------------------------------------------
@Test
public void factory_of_LocalDateLocalTimeZoneOffset() {
LocalDate date = LocalDate.of(2008, 6, 30);
LocalTime time = LocalTime.of(11, 30, 10, 500);
OffsetDateTime test = OffsetDateTime.of(date, time, OFFSET_PONE);
check(test, 2008, 6, 30, 11, 30, 10, 500, OFFSET_PONE);
}
use of java.time.LocalTime in project jdk8u_jdk by JetBrains.
the class TCKLocalTime method test_plusHours_noChange_equal.
@Test
public void test_plusHours_noChange_equal() {
LocalTime t = TEST_12_30_40_987654321.plusHours(0);
assertEquals(t, TEST_12_30_40_987654321);
}
Aggregations