use of java.time.LocalTime in project jdk8u_jdk by JetBrains.
the class TimeTests method test09.
/*
* Validate that a Time made from a toLocalTime() LocalTime are equal
*/
@Test
public void test09() {
Time t = Time.valueOf("08:30:59");
Time t2 = Time.valueOf(t.toLocalTime());
assertTrue(t.equals(t2), "Error t != t2");
}
use of java.time.LocalTime in project jdk8u_jdk by JetBrains.
the class TCKLocalTime method test_with_longTemporalField_minuteOfHour.
// Returns a {@code LocalTime} with the specified minute-of-hour.
// The hour, second-of-minute and nano-of-second will be unchanged.
@Test
public void test_with_longTemporalField_minuteOfHour() {
for (long i : testPoints(60)) {
LocalTime test = TEST_12_30_40_987654321.with(MINUTE_OF_HOUR, i);
assertEquals(test.get(MINUTE_OF_HOUR), i);
assertEquals(test.get(HOUR_OF_DAY), TEST_12_30_40_987654321.get(HOUR_OF_DAY));
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 test_plusHours_fromZero.
@Test
public void test_plusHours_fromZero() {
LocalTime base = LocalTime.MIDNIGHT;
for (int i = -50; i < 50; i++) {
LocalTime t = base.plusHours(i);
assertEquals(t.getHour(), (i + 72) % 24);
}
}
use of java.time.LocalTime in project jdk8u_jdk by JetBrains.
the class TCKLocalTime method test_plusNanos_halfABillion.
//-----------------------------------------------------------------------
// plusNanos()
//-----------------------------------------------------------------------
@Test
public void test_plusNanos_halfABillion() {
LocalTime t = LocalTime.MIDNIGHT;
int hour = 0;
int min = 0;
int sec = 0;
int nanos = 0;
for (long i = 0; i < 3700 * 1000000000L; i += 500000000) {
t = t.plusNanos(500000000);
nanos += 500000000;
if (nanos == 1000000000) {
sec++;
nanos = 0;
}
if (sec == 60) {
min++;
sec = 0;
}
if (min == 60) {
hour++;
min = 0;
}
assertEquals(t.getHour(), hour);
assertEquals(t.getMinute(), min);
assertEquals(t.getSecond(), sec);
assertEquals(t.getNano(), nanos);
}
}
use of java.time.LocalTime in project jdk8u_jdk by JetBrains.
the class TCKLocalTime method factory_parse_formatter.
//-----------------------------------------------------------------------
// parse(DateTimeFormatter)
//-----------------------------------------------------------------------
@Test
public void factory_parse_formatter() {
DateTimeFormatter f = DateTimeFormatter.ofPattern("H m s");
LocalTime test = LocalTime.parse("14 30 40", f);
assertEquals(test, LocalTime.of(14, 30, 40));
}
Aggregations