Search in sources :

Example 46 with LocalDateTime

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);
    }
}
Also used : LocalDateTime(java.time.LocalDateTime) Test(org.testng.annotations.Test)

Example 47 with LocalDateTime

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));
}
Also used : LocalDateTime(java.time.LocalDateTime) Test(org.testng.annotations.Test)

Example 48 with LocalDateTime

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);
}
Also used : LocalDateTime(java.time.LocalDateTime) Test(org.testng.annotations.Test)

Example 49 with LocalDateTime

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);
}
Also used : LocalDateTime(java.time.LocalDateTime) Test(org.testng.annotations.Test)

Example 50 with LocalDateTime

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);
}
Also used : LocalDateTime(java.time.LocalDateTime) DataOutputStream(java.io.DataOutputStream) ByteArrayOutputStream(java.io.ByteArrayOutputStream) Test(org.testng.annotations.Test) AbstractTCKTest(tck.java.time.AbstractTCKTest)

Aggregations

LocalDateTime (java.time.LocalDateTime)484 Test (org.testng.annotations.Test)282 Test (org.junit.Test)66 ZonedDateTime (java.time.ZonedDateTime)53 LocalDate (java.time.LocalDate)49 LocalTime (java.time.LocalTime)28 ZoneOffsetTransition (java.time.zone.ZoneOffsetTransition)26 Instant (java.time.Instant)20 DateTimeFormatter (java.time.format.DateTimeFormatter)20 List (java.util.List)18 Date (java.util.Date)17 ZoneId (java.time.ZoneId)16 AbstractTCKTest (tck.java.time.AbstractTCKTest)14 ArrayList (java.util.ArrayList)12 HashMap (java.util.HashMap)12 OffsetDateTime (java.time.OffsetDateTime)11 ZoneOffset (java.time.ZoneOffset)11 DateTimeParseException (java.time.format.DateTimeParseException)11 ZoneRules (java.time.zone.ZoneRules)10 IOException (java.io.IOException)9