use of java.time.LocalTime in project jdk8u_jdk by JetBrains.
the class TestLocalDateTime method test_getTime.
//-----------------------------------------------------------------------
// toLocalTime()
//-----------------------------------------------------------------------
@Test(dataProvider = "sampleTimes")
public void test_getTime(int h, int m, int s, int ns) {
LocalTime t = LocalTime.of(h, m, s, ns);
LocalDateTime dt = LocalDateTime.of(LocalDate.of(2011, 7, 30), t);
assertSame(dt.toLocalTime(), t);
}
use of java.time.LocalTime in project jdk8u_jdk by JetBrains.
the class TCKLocalTime method test_minusSeconds_toMidnight_equal.
@Test
public void test_minusSeconds_toMidnight_equal() {
LocalTime t = LocalTime.of(0, 0, 1).minusSeconds(1);
assertEquals(t, LocalTime.MIDNIGHT);
}
use of java.time.LocalTime in project jdk8u_jdk by JetBrains.
the class TCKLocalTime method test_with_longTemporalField_notChronoField.
// If the field is not a {@code ChronoField}, then the result of this method
// is obtained by invoking {@code TemporalField.adjustInto(Temporal, long)}
// passing {@code this} as the argument.
@Test
public void test_with_longTemporalField_notChronoField() {
final LocalTime result = LocalTime.of(12, 30);
final LocalTime base = LocalTime.of(15, 45);
TemporalField field = new TemporalField() {
public ValueRange rangeRefinedBy(TemporalAccessor temporal) {
throw new UnsupportedOperationException();
}
public ValueRange range() {
return null;
}
public boolean isTimeBased() {
throw new UnsupportedOperationException();
}
public boolean isSupportedBy(TemporalAccessor temporal) {
throw new UnsupportedOperationException();
}
public boolean isDateBased() {
throw new UnsupportedOperationException();
}
public TemporalUnit getRangeUnit() {
throw new UnsupportedOperationException();
}
public long getFrom(TemporalAccessor temporal) {
throw new UnsupportedOperationException();
}
public TemporalUnit getBaseUnit() {
throw new UnsupportedOperationException();
}
public <R extends Temporal> R adjustInto(R temporal, long newValue) {
assertEquals(temporal, base);
assertEquals(newValue, 12L);
@SuppressWarnings("unchecked") R r = (R) result;
return r;
}
};
LocalTime test = base.with(field, 12L);
assertSame(test, result);
}
use of java.time.LocalTime in project jdk8u_jdk by JetBrains.
the class TCKLocalTime method test_plusSeconds_toMidday_equal.
@Test
public void test_plusSeconds_toMidday_equal() {
LocalTime t = LocalTime.of(11, 59, 59).plusSeconds(1);
assertEquals(t, LocalTime.NOON);
}
use of java.time.LocalTime in project jdk8u_jdk by JetBrains.
the class TCKLocalTime method test_minus_longTemporalUnit_zero.
@Test
public void test_minus_longTemporalUnit_zero() {
LocalTime t = TEST_12_30_40_987654321.minus(0, ChronoUnit.MINUTES);
assertEquals(t, TEST_12_30_40_987654321);
}
Aggregations