< prev index next >

test/java/time/tck/java/time/TCKLocalDate.java

Print this page

        

@@ -2155,10 +2155,34 @@
         assertEquals(LocalDate.of(1970, 1, 1).toEpochDay(), 0);
         assertEquals(LocalDate.of(-1, 12, 31).toEpochDay(), -678942 - 40587);
     }
 
     //-----------------------------------------------------------------------
+    // toEpochSecond
+    //-----------------------------------------------------------------------
+    @DataProvider(name="epochSecond")
+    Object[][] provider_toEpochSecond() {
+        return new Object[][] {
+            {LocalDate.of(1858, 11, 17).toEpochSecond(OFFSET_PONE), -3506720400L},
+            {LocalDate.of(1, 1, 1).toEpochSecond(OFFSET_PONE), -62135600400L},
+            {LocalDate.of(1995, 9, 27).toEpochSecond(OFFSET_PONE), 812156400L},
+            {LocalDate.of(1970, 1, 1).toEpochSecond(OFFSET_PONE), -3600L},
+            {LocalDate.of(-1, 12, 31).toEpochSecond(OFFSET_PONE), -62167309200L},
+            {LocalDate.of(1, 1, 1).toEpochSecond(OFFSET_PONE),
+             Instant.ofEpochSecond(-62135600400L).getEpochSecond()},
+            {LocalDate.of(1995, 9, 27).toEpochSecond(OFFSET_PONE),
+             Instant.ofEpochSecond(812156400L).getEpochSecond()},
+            {LocalDate.of(1995, 9, 27).toEpochSecond(OFFSET_PONE),
+             LocalDateTime.of(1995, 9, 27, 0, 0).toEpochSecond(OFFSET_PONE)},
+        };
+    }
+
+    @Test(dataProvider="epochSecond")
+    public void test_toEpochSecond(long actual, long expected) {
+        assertEquals(actual, expected);
+    }
+    //-----------------------------------------------------------------------
     // compareTo()
     //-----------------------------------------------------------------------
     @Test
     public void test_comparisons() {
         doTest_comparisons_LocalDate(
< prev index next >