Search in sources :

Example 21 with LocalDateTime

use of java.time.LocalDateTime in project jdk8u_jdk by JetBrains.

the class TCKLocalDateTime method test_with_adjustment.

//-----------------------------------------------------------------------
// with()
//-----------------------------------------------------------------------
@Test
public void test_with_adjustment() {
    final LocalDateTime sample = LocalDateTime.of(2012, 3, 4, 23, 5);
    TemporalAdjuster adjuster = new TemporalAdjuster() {

        @Override
        public Temporal adjustInto(Temporal dateTime) {
            return sample;
        }
    };
    assertEquals(TEST_2007_07_15_12_30_40_987654321.with(adjuster), sample);
}
Also used : LocalDateTime(java.time.LocalDateTime) Temporal(java.time.temporal.Temporal) TemporalAdjuster(java.time.temporal.TemporalAdjuster) Test(org.testng.annotations.Test)

Example 22 with LocalDateTime

use of java.time.LocalDateTime in project jdk8u_jdk by JetBrains.

the class TCKLocalDateTime method test_plusMonths_int_normal.

//-----------------------------------------------------------------------
// plusMonths()
//-----------------------------------------------------------------------
@Test
public void test_plusMonths_int_normal() {
    LocalDateTime t = TEST_2007_07_15_12_30_40_987654321.plusMonths(1);
    check(t, 2007, 8, 15, 12, 30, 40, 987654321);
}
Also used : LocalDateTime(java.time.LocalDateTime) Test(org.testng.annotations.Test)

Example 23 with LocalDateTime

use of java.time.LocalDateTime in project jdk8u_jdk by JetBrains.

the class TCKLocalDateTime method test_atZone_Offset.

@Test
public void test_atZone_Offset() {
    LocalDateTime t = LocalDateTime.of(2008, 6, 30, 11, 30);
    assertEquals(t.atZone(OFFSET_PTWO), ZonedDateTime.of(LocalDateTime.of(2008, 6, 30, 11, 30), OFFSET_PTWO));
}
Also used : LocalDateTime(java.time.LocalDateTime) Test(org.testng.annotations.Test)

Example 24 with LocalDateTime

use of java.time.LocalDateTime in project jdk8u_jdk by JetBrains.

the class TCKLocalDateTime method factory_of_5ints.

//-----------------------------------------------------------------------
@Test
public void factory_of_5ints() {
    LocalDateTime dateTime = LocalDateTime.of(2007, 7, 15, 12, 30);
    check(dateTime, 2007, 7, 15, 12, 30, 0, 0);
}
Also used : LocalDateTime(java.time.LocalDateTime) Test(org.testng.annotations.Test)

Example 25 with LocalDateTime

use of java.time.LocalDateTime in project jdk8u_jdk by JetBrains.

the class TCKLocalDateTime method test_plusNanos_noChange_oneDay.

@Test
public void test_plusNanos_noChange_oneDay() {
    LocalDateTime t = TEST_2007_07_15_12_30_40_987654321.plusNanos(24 * 60 * 60 * 1000000000L);
    assertEquals(t.toLocalDate(), TEST_2007_07_15_12_30_40_987654321.toLocalDate().plusDays(1));
}
Also used : LocalDateTime(java.time.LocalDateTime) Test(org.testng.annotations.Test)

Aggregations

LocalDateTime (java.time.LocalDateTime)399 Test (org.testng.annotations.Test)280 ZonedDateTime (java.time.ZonedDateTime)45 Test (org.junit.Test)40 LocalDate (java.time.LocalDate)33 ZoneOffsetTransition (java.time.zone.ZoneOffsetTransition)26 LocalTime (java.time.LocalTime)20 Instant (java.time.Instant)19 DateTimeFormatter (java.time.format.DateTimeFormatter)16 ZoneId (java.time.ZoneId)15 AbstractTCKTest (tck.java.time.AbstractTCKTest)14 OffsetDateTime (java.time.OffsetDateTime)10 ZoneRules (java.time.zone.ZoneRules)10 ZoneOffset (java.time.ZoneOffset)9 Date (java.util.Date)8 List (java.util.List)8 ArrayList (java.util.ArrayList)7 HashMap (java.util.HashMap)7 Timestamp (java.sql.Timestamp)6 ChronoLocalDateTime (java.time.chrono.ChronoLocalDateTime)6