use of java.time.LocalDateTime in project jdk8u_jdk by JetBrains.
the class TCKLocalDateTime method test_withHour_normal.
//-----------------------------------------------------------------------
// withHour()
//-----------------------------------------------------------------------
@Test
public void test_withHour_normal() {
LocalDateTime t = TEST_2007_07_15_12_30_40_987654321;
for (int i = 0; i < 24; i++) {
t = t.withHour(i);
assertEquals(t.getHour(), i);
}
}
use of java.time.LocalDateTime in project jdk8u_jdk by JetBrains.
the class TCKLocalDateTime method test_minus_TemporalAmount_positiveMonths.
//-----------------------------------------------------------------------
// minus(TemporalAmount)
//-----------------------------------------------------------------------
@Test
public void test_minus_TemporalAmount_positiveMonths() {
MockSimplePeriod period = MockSimplePeriod.of(7, MONTHS);
LocalDateTime t = TEST_2007_07_15_12_30_40_987654321.minus(period);
assertEquals(t, LocalDateTime.of(2006, 12, 15, 12, 30, 40, 987654321));
}
use of java.time.LocalDateTime in project jdk8u_jdk by JetBrains.
the class TCKLocalDateTime method test_minusMonths_int_adjustDayFromMonthLength.
@Test
public void test_minusMonths_int_adjustDayFromMonthLength() {
LocalDateTime t = createDateMidnight(2007, 3, 31).minusMonths(1);
check(t, 2007, 2, 28, 0, 0, 0, 0);
}
use of java.time.LocalDateTime in project jdk8u_jdk by JetBrains.
the class TCKLocalDateTime method test_minusMonths_int_negative.
@Test
public void test_minusMonths_int_negative() {
LocalDateTime t = TEST_2007_07_15_12_30_40_987654321.minusMonths(-1);
check(t, 2007, 8, 15, 12, 30, 40, 987654321);
}
use of java.time.LocalDateTime in project jdk8u_jdk by JetBrains.
the class TCKOffsetDateTimeSerialization method test_serialization_format.
@Test
public void test_serialization_format() throws Exception {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
try (DataOutputStream dos = new DataOutputStream(baos)) {
// java.time.Ser.OFFSET_DATE_TIME_TYPE
dos.writeByte(10);
dos.writeInt(2012);
dos.writeByte(9);
dos.writeByte(16);
dos.writeByte(22);
dos.writeByte(17);
dos.writeByte(59);
dos.writeInt(464_000_000);
// quarter hours stored: 3600 / 900
dos.writeByte(4);
}
byte[] bytes = baos.toByteArray();
LocalDateTime ldt = LocalDateTime.of(2012, 9, 16, 22, 17, 59, 464_000_000);
assertSerializedBySer(OffsetDateTime.of(ldt, ZoneOffset.ofHours(1)), bytes);
}
Aggregations