Search in sources :

Example 31 with LocalTime

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

the class TCKLocalTime method test_minusSeconds_one.

//-----------------------------------------------------------------------
// minusSeconds()
//-----------------------------------------------------------------------
@Test
public void test_minusSeconds_one() {
    LocalTime t = LocalTime.MIDNIGHT;
    int hour = 0;
    int min = 0;
    int sec = 0;
    for (int i = 0; i < 3700; i++) {
        t = t.minusSeconds(1);
        sec--;
        if (sec == -1) {
            min--;
            sec = 59;
            if (min == -1) {
                hour--;
                min = 59;
                if (hour == -1) {
                    hour = 23;
                }
            }
        }
        assertEquals(t.getHour(), hour);
        assertEquals(t.getMinute(), min);
        assertEquals(t.getSecond(), sec);
    }
}
Also used : LocalTime(java.time.LocalTime) Test(org.testng.annotations.Test)

Example 32 with LocalTime

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

the class TCKLocalTime method test_withSecond_toMidday_equal.

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

Example 33 with LocalTime

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

the class TCKLocalTime method test_until_invalidType.

@Test(expectedExceptions = DateTimeException.class)
public void test_until_invalidType() {
    LocalTime start = LocalTime.of(11, 30);
    start.until(LocalDate.of(2010, 6, 30), SECONDS);
}
Also used : LocalTime(java.time.LocalTime) Test(org.testng.annotations.Test)

Example 34 with LocalTime

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

the class TCKLocalTime method test_hashCode_hour_differs.

@Test(dataProvider = "sampleTimes")
public void test_hashCode_hour_differs(int h, int m, int s, int n) {
    LocalTime a = LocalTime.of(h, m, s, n);
    LocalTime b = LocalTime.of(h + 1, m, s, n);
    assertEquals(a.hashCode() == b.hashCode(), false);
}
Also used : LocalTime(java.time.LocalTime) Test(org.testng.annotations.Test)

Example 35 with LocalTime

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

the class TCKLocalTime method now_ZoneId.

@Test
public void now_ZoneId() {
    ZoneId zone = ZoneId.of("UTC+01:02:03");
    LocalTime expected = LocalTime.now(Clock.system(zone));
    LocalTime test = LocalTime.now(zone);
    for (int i = 0; i < 100; i++) {
        if (expected.equals(test)) {
            return;
        }
        expected = LocalTime.now(Clock.system(zone));
        test = LocalTime.now(zone);
    }
    assertEquals(test, expected);
}
Also used : ZoneId(java.time.ZoneId) LocalTime(java.time.LocalTime) 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