Search in sources :

Example 71 with LocalTime

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

the class TCKLocalTime method test_with_longTemporalField_amPmOfDay.

// Returns a {@code LocalTime} with the specified AM/PM.
// The hour-of-am-pm, minute-of-hour, second-of-minute and nano-of-second will be unchanged.
@Test
public void test_with_longTemporalField_amPmOfDay() {
    for (int i = 0; i <= 1; i++) {
        LocalTime test = TEST_12_30_40_987654321.with(AMPM_OF_DAY, i);
        assertEquals(test.get(AMPM_OF_DAY), i);
        assertEquals(test.get(HOUR_OF_AMPM), TEST_12_30_40_987654321.get(HOUR_OF_AMPM));
        assertEquals(test.get(MINUTE_OF_HOUR), TEST_12_30_40_987654321.get(MINUTE_OF_HOUR));
        assertEquals(test.get(SECOND_OF_MINUTE), TEST_12_30_40_987654321.get(SECOND_OF_MINUTE));
        assertEquals(test.get(NANO_OF_SECOND), TEST_12_30_40_987654321.get(NANO_OF_SECOND));
    }
}
Also used : LocalTime(java.time.LocalTime) Test(org.testng.annotations.Test)

Example 72 with LocalTime

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

the class TCKLocalTime method now_Clock_beforeEpoch.

@Test
public void now_Clock_beforeEpoch() {
    for (int i = -1; i >= -(24 * 60 * 60); i--) {
        Instant instant = Instant.ofEpochSecond(i, 8);
        Clock clock = Clock.fixed(instant, ZoneOffset.UTC);
        LocalTime test = LocalTime.now(clock);
        assertEquals(test.getHour(), ((i + 24 * 60 * 60) / (60 * 60)) % 24);
        assertEquals(test.getMinute(), ((i + 24 * 60 * 60) / 60) % 60);
        assertEquals(test.getSecond(), (i + 24 * 60 * 60) % 60);
        assertEquals(test.getNano(), 8);
    }
}
Also used : LocalTime(java.time.LocalTime) Instant(java.time.Instant) Clock(java.time.Clock) Test(org.testng.annotations.Test)

Example 73 with LocalTime

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

the class TCKLocalTime method test_hashCode_second_differs.

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

Example 74 with LocalTime

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

the class TCKOffsetDateTime method factory_of_LocalDateLocalTimeZoneOffset.

//-----------------------------------------------------------------------
@Test
public void factory_of_LocalDateLocalTimeZoneOffset() {
    LocalDate date = LocalDate.of(2008, 6, 30);
    LocalTime time = LocalTime.of(11, 30, 10, 500);
    OffsetDateTime test = OffsetDateTime.of(date, time, OFFSET_PONE);
    check(test, 2008, 6, 30, 11, 30, 10, 500, OFFSET_PONE);
}
Also used : LocalTime(java.time.LocalTime) OffsetDateTime(java.time.OffsetDateTime) LocalDate(java.time.LocalDate) Test(org.testng.annotations.Test)

Example 75 with LocalTime

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

the class TCKLocalTime method test_plusHours_noChange_equal.

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

Aggregations

LocalTime (java.time.LocalTime)676 Test (org.junit.Test)262 Test (org.testng.annotations.Test)173 LocalDate (java.time.LocalDate)156 LocalDateTime (java.time.LocalDateTime)130 ZonedDateTime (java.time.ZonedDateTime)36 Date (java.util.Date)32 Instant (java.time.Instant)30 OffsetDateTime (java.time.OffsetDateTime)30 DateTimeFormatter (java.time.format.DateTimeFormatter)27 Test (org.junit.jupiter.api.Test)27 UseDataProvider (com.tngtech.java.junit.dataprovider.UseDataProvider)23 ZoneOffset (java.time.ZoneOffset)23 ZoneId (java.time.ZoneId)22 ArrayList (java.util.ArrayList)19 BigDecimal (java.math.BigDecimal)18 TemporalAccessor (java.time.temporal.TemporalAccessor)18 TemporalAmount (java.time.temporal.TemporalAmount)18 Time (java.sql.Time)17 Clock (java.time.Clock)17