Search in sources :

Example 41 with LocalTime

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

the class TCKLocalTime method test_withSecond_toMidnight_equal.

@Test
public void test_withSecond_toMidnight_equal() {
    LocalTime t = LocalTime.of(0, 0, 1).withSecond(0);
    assertEquals(t, LocalTime.MIDNIGHT);
}
Also used : LocalTime(java.time.LocalTime) Test(org.testng.annotations.Test)

Example 42 with LocalTime

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

the class TCKLocalTime method test_plusNanos_toMidday_equal.

@Test
public void test_plusNanos_toMidday_equal() {
    LocalTime t = LocalTime.of(11, 59, 59, 999999999).plusNanos(1);
    assertEquals(t, LocalTime.NOON);
}
Also used : LocalTime(java.time.LocalTime) Test(org.testng.annotations.Test)

Example 43 with LocalTime

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

the class TCKLocalTime method test_plusMinutes_noChange_equal.

@Test
public void test_plusMinutes_noChange_equal() {
    LocalTime t = TEST_12_30_40_987654321.plusMinutes(0);
    assertEquals(t, TEST_12_30_40_987654321);
}
Also used : LocalTime(java.time.LocalTime) Test(org.testng.annotations.Test)

Example 44 with LocalTime

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

the class TCKLocalTime method test_minusMinutes_toMidnight_equal.

@Test
public void test_minusMinutes_toMidnight_equal() {
    LocalTime t = LocalTime.of(0, 1).minusMinutes(1);
    assertEquals(t, LocalTime.MIDNIGHT);
}
Also used : LocalTime(java.time.LocalTime) Test(org.testng.annotations.Test)

Example 45 with LocalTime

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

the class TCKZonedDateTime method test_get.

@Test(dataProvider = "sampleTimes")
public void test_get(int y, int o, int d, int h, int m, int s, int n, ZoneId zone) {
    LocalDate localDate = LocalDate.of(y, o, d);
    LocalTime localTime = LocalTime.of(h, m, s, n);
    LocalDateTime localDateTime = LocalDateTime.of(localDate, localTime);
    ZoneOffset offset = zone.getRules().getOffset(localDateTime);
    ZonedDateTime a = ZonedDateTime.of(localDateTime, zone);
    assertEquals(a.getYear(), localDate.getYear());
    assertEquals(a.getMonth(), localDate.getMonth());
    assertEquals(a.getDayOfMonth(), localDate.getDayOfMonth());
    assertEquals(a.getDayOfYear(), localDate.getDayOfYear());
    assertEquals(a.getDayOfWeek(), localDate.getDayOfWeek());
    assertEquals(a.getHour(), localTime.getHour());
    assertEquals(a.getMinute(), localTime.getMinute());
    assertEquals(a.getSecond(), localTime.getSecond());
    assertEquals(a.getNano(), localTime.getNano());
    assertEquals(a.toLocalDate(), localDate);
    assertEquals(a.toLocalTime(), localTime);
    assertEquals(a.toLocalDateTime(), localDateTime);
    if (zone instanceof ZoneOffset) {
        assertEquals(a.toString(), localDateTime.toString() + offset.toString());
    } else {
        assertEquals(a.toString(), localDateTime.toString() + offset.toString() + "[" + zone.toString() + "]");
    }
}
Also used : LocalDateTime(java.time.LocalDateTime) LocalTime(java.time.LocalTime) ZonedDateTime(java.time.ZonedDateTime) LocalDate(java.time.LocalDate) ZoneOffset(java.time.ZoneOffset) Test(org.testng.annotations.Test)

Aggregations

LocalTime (java.time.LocalTime)213 Test (org.testng.annotations.Test)164 LocalDate (java.time.LocalDate)31 LocalDateTime (java.time.LocalDateTime)27 ZonedDateTime (java.time.ZonedDateTime)14 Test (org.junit.Test)14 Instant (java.time.Instant)11 Clock (java.time.Clock)8 OffsetDateTime (java.time.OffsetDateTime)8 TemporalAmount (java.time.temporal.TemporalAmount)8 DayOfWeek (java.time.DayOfWeek)7 DateTimeFormatter (java.time.format.DateTimeFormatter)7 Time (java.sql.Time)6 ZoneId (java.time.ZoneId)6 TemporalAccessor (java.time.temporal.TemporalAccessor)6 TimetableItem (de.hpi.bpt.scylla.model.global.resource.TimetableItem)5 OffsetTime (java.time.OffsetTime)5 Temporal (java.time.temporal.Temporal)5 Date (java.util.Date)5 Duration (java.time.Duration)4