Search in sources :

Example 86 with LocalDateTime

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

the class TCKLocalDateTime method factory_of_4intsMonth.

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

Example 87 with LocalDateTime

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

the class TCKLocalDateTime method test_plusWeeks_symmetry.

@Test(dataProvider = "samplePlusWeeksSymmetry")
public void test_plusWeeks_symmetry(LocalDateTime reference) {
    for (int weeks = 0; weeks < 365 * 8; weeks++) {
        LocalDateTime t = reference.plusWeeks(weeks).plusWeeks(-weeks);
        assertEquals(t, reference);
        t = reference.plusWeeks(-weeks).plusWeeks(weeks);
        assertEquals(t, reference);
    }
}
Also used : LocalDateTime(java.time.LocalDateTime) Test(org.testng.annotations.Test)

Example 88 with LocalDateTime

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

the class TCKLocalDateTime method test_minusWeeks_negativeOverYears.

@Test
public void test_minusWeeks_negativeOverYears() {
    LocalDateTime t = TEST_2007_07_15_12_30_40_987654321.minusWeeks(-104);
    check(t, 2009, 7, 12, 12, 30, 40, 987654321);
}
Also used : LocalDateTime(java.time.LocalDateTime) Test(org.testng.annotations.Test)

Example 89 with LocalDateTime

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

the class TCKLocalDateTime method factory_ofEpochSecond_longOffset_beforeEpoch.

@Test
public void factory_ofEpochSecond_longOffset_beforeEpoch() {
    LocalDateTime base = LocalDateTime.of(1970, 1, 1, 2, 0, 0, 500);
    for (int i = 0; i < 100000; i++) {
        LocalDateTime test = LocalDateTime.ofEpochSecond(-i, 500, OFFSET_PTWO);
        assertEquals(test, base.minusSeconds(i));
    }
}
Also used : LocalDateTime(java.time.LocalDateTime) Test(org.testng.annotations.Test)

Example 90 with LocalDateTime

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

the class TCKLocalDateTime method test_until_convertedType.

@Test
public void test_until_convertedType() {
    LocalDateTime start = LocalDateTime.of(2010, 6, 30, 2, 30);
    OffsetDateTime end = start.plusDays(2).atOffset(OFFSET_PONE);
    assertEquals(start.until(end, DAYS), 2);
}
Also used : LocalDateTime(java.time.LocalDateTime) OffsetDateTime(java.time.OffsetDateTime) Test(org.testng.annotations.Test)

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