< prev index next >

test/java/time/tck/java/time/TCKLocalTime.java

Print this page

        

*** 2431,2440 **** --- 2431,2465 ---- assertEquals(t.toSecondOfDay(), i); t = t.plusSeconds(1); } } + //----------------------------------------------------------------------- + // toEpochSecond() + //-------------------------------------------------------------------------- + @DataProvider(name="epochSecond") + Object[][] provider__toEpochSecond() { + return new Object[][] { + {LocalTime.of(0, 0).toEpochSecond(OFFSET_PTWO), -7200}, + {LocalTime.of(11, 30).toEpochSecond(OFFSET_PTWO), 34200}, + {LocalTime.of(0, 0).toEpochSecond(OFFSET_PTWO), + Instant.ofEpochSecond(-7200).getEpochSecond()}, + {LocalTime.of(11, 30).toEpochSecond(OFFSET_PTWO), + Instant.ofEpochSecond(34200).getEpochSecond()}, + {LocalTime.of(11, 30).toEpochSecond(OFFSET_PTWO), + LocalDateTime.of(1970, 1, 1, 11, 30).toEpochSecond(OFFSET_PTWO)}, + }; + } + + @Test(dataProvider="epochSecond") + public void test_toEpochSecond(long actual, long expected) { + assertEquals(actual, expected); + } + + //----------------------------------------------------------------------- + // toSecondOfDay_fromNanoOfDay_symmetry() + //----------------------------------------------------------------------- @Test public void test_toSecondOfDay_fromNanoOfDay_symmetry() { LocalTime t = LocalTime.of(0, 0); for (int i = 0; i < 24 * 60 * 60; i++) { assertEquals(LocalTime.ofSecondOfDay(t.toSecondOfDay()), t);
< prev index next >