Search in sources :

Example 61 with LocalDateTime

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

the class TCKZonedDateTime method test_withZoneSameLocal.

//-----------------------------------------------------------------------
// withZoneSameLocal(ZoneId)
//-----------------------------------------------------------------------
@Test
public void test_withZoneSameLocal() {
    LocalDateTime ldt = LocalDateTime.of(2008, 6, 30, 23, 30, 59, 0);
    ZonedDateTime base = ZonedDateTime.of(ldt, ZONE_0100);
    ZonedDateTime test = base.withZoneSameLocal(ZONE_0200);
    assertEquals(test.toLocalDateTime(), base.toLocalDateTime());
}
Also used : LocalDateTime(java.time.LocalDateTime) ZonedDateTime(java.time.ZonedDateTime) Test(org.testng.annotations.Test)

Example 62 with LocalDateTime

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

the class TCKZonedDateTime method test_toEpochSecond_afterEpoch.

//-----------------------------------------------------------------------
// toEpochSecond()
//-----------------------------------------------------------------------
@Test
public void test_toEpochSecond_afterEpoch() {
    LocalDateTime ldt = LocalDateTime.of(1970, 1, 1, 0, 0).plusHours(1);
    for (int i = 0; i < 100000; i++) {
        ZonedDateTime a = ZonedDateTime.of(ldt, ZONE_PARIS);
        assertEquals(a.toEpochSecond(), i);
        ldt = ldt.plusSeconds(1);
    }
}
Also used : LocalDateTime(java.time.LocalDateTime) ZonedDateTime(java.time.ZonedDateTime) Test(org.testng.annotations.Test)

Example 63 with LocalDateTime

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

the class TCKZonedDateTime method factory_of_LocalDateTime_nullZone.

@Test(expectedExceptions = NullPointerException.class)
public void factory_of_LocalDateTime_nullZone() {
    LocalDateTime base = LocalDateTime.of(2008, 6, 30, 11, 30, 10, 500);
    ZonedDateTime.of(base, null);
}
Also used : LocalDateTime(java.time.LocalDateTime) Test(org.testng.annotations.Test)

Example 64 with LocalDateTime

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

the class TCKZonedDateTime method test_withZoneSameLocal_null.

@Test(expectedExceptions = NullPointerException.class)
public void test_withZoneSameLocal_null() {
    LocalDateTime ldt = LocalDateTime.of(2008, 6, 30, 23, 30, 59, 0);
    ZonedDateTime base = ZonedDateTime.of(ldt, ZONE_0100);
    base.withZoneSameLocal(null);
}
Also used : LocalDateTime(java.time.LocalDateTime) ZonedDateTime(java.time.ZonedDateTime) Test(org.testng.annotations.Test)

Example 65 with LocalDateTime

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

the class TCKZonedDateTime method test_withZoneSameLocal_retainOffset1.

@Test
public void test_withZoneSameLocal_retainOffset1() {
    // overlap
    LocalDateTime ldt = LocalDateTime.of(2008, 11, 2, 1, 30, 59, 0);
    ZonedDateTime base = ZonedDateTime.of(ldt, ZoneId.of("UTC-04:00"));
    ZonedDateTime test = base.withZoneSameLocal(ZoneId.of("America/New_York"));
    assertEquals(base.getOffset(), ZoneOffset.ofHours(-4));
    assertEquals(test.getOffset(), ZoneOffset.ofHours(-4));
}
Also used : LocalDateTime(java.time.LocalDateTime) ZonedDateTime(java.time.ZonedDateTime) 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