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

Print this page




  63 import static java.time.temporal.ChronoField.ALIGNED_DAY_OF_WEEK_IN_YEAR;
  64 import static java.time.temporal.ChronoField.ALIGNED_WEEK_OF_MONTH;
  65 import static java.time.temporal.ChronoField.ALIGNED_WEEK_OF_YEAR;
  66 import static java.time.temporal.ChronoField.DAY_OF_MONTH;
  67 import static java.time.temporal.ChronoField.DAY_OF_WEEK;
  68 import static java.time.temporal.ChronoField.DAY_OF_YEAR;
  69 import static java.time.temporal.ChronoField.EPOCH_DAY;
  70 import static java.time.temporal.ChronoField.EPOCH_MONTH;
  71 import static java.time.temporal.ChronoField.ERA;
  72 import static java.time.temporal.ChronoField.MONTH_OF_YEAR;
  73 import static java.time.temporal.ChronoField.YEAR;
  74 import static java.time.temporal.ChronoField.YEAR_OF_ERA;
  75 import static org.testng.Assert.assertEquals;
  76 import static org.testng.Assert.assertFalse;
  77 import static org.testng.Assert.assertNotNull;
  78 import static org.testng.Assert.assertSame;
  79 import static org.testng.Assert.assertTrue;
  80 
  81 import java.io.ByteArrayOutputStream;
  82 import java.io.DataOutputStream;
  83 import java.io.IOException;
  84 import java.util.ArrayList;
  85 import java.util.Arrays;
  86 import java.util.List;
  87 
  88 import java.time.Clock;
  89 import java.time.DateTimeException;
  90 import java.time.DayOfWeek;
  91 import java.time.Instant;
  92 import java.time.LocalDate;
  93 import java.time.LocalDateTime;
  94 import java.time.LocalTime;
  95 import java.time.Month;




  96 import java.time.ZoneId;
  97 import java.time.ZoneOffset;
  98 import java.time.ZonedDateTime;

  99 import java.time.format.DateTimeFormatter;
 100 import java.time.format.DateTimeFormatters;
 101 import java.time.format.DateTimeParseException;
 102 import java.time.temporal.ChronoField;
 103 import java.time.temporal.ChronoUnit;
 104 import java.time.temporal.ISOChrono;
 105 import java.time.temporal.JulianFields;
 106 import java.time.temporal.OffsetDate;
 107 import java.time.temporal.Queries;
 108 import java.time.temporal.Temporal;
 109 import java.time.temporal.TemporalAccessor;
 110 import java.time.temporal.TemporalAdjuster;
 111 import java.time.temporal.TemporalField;

 112 import java.time.temporal.TemporalUnit;
 113 import java.time.temporal.Year;


 114 
 115 import org.testng.annotations.BeforeMethod;
 116 import org.testng.annotations.DataProvider;
 117 import org.testng.annotations.Test;
 118 import test.java.time.MockSimplePeriod;
 119 import test.java.time.temporal.MockFieldNoValue;
 120 
 121 /**
 122  * Test LocalDate.
 123  */
 124 @Test
 125 public class TCKLocalDate extends AbstractDateTimeTest {
 126 
 127     private static final ZoneOffset OFFSET_PONE = ZoneOffset.ofHours(1);
 128     private static final ZoneOffset OFFSET_PTWO = ZoneOffset.ofHours(2);
 129     private static final ZoneId ZONE_PARIS = ZoneId.of("Europe/Paris");
 130     private static final ZoneId ZONE_GAZA = ZoneId.of("Asia/Gaza");
 131 
 132     private LocalDate TEST_2007_07_15;
 133     private long MAX_VALID_EPOCHDAYS;


 578     @Test(expectedExceptions=DateTimeParseException.class, groups={"tck"})
 579     public void factory_parse_illegalValue() {
 580         LocalDate.parse("2008-06-32");
 581     }
 582 
 583     @Test(expectedExceptions=DateTimeParseException.class, groups={"tck"})
 584     public void factory_parse_invalidValue() {
 585         LocalDate.parse("2008-06-31");
 586     }
 587 
 588     @Test(expectedExceptions=NullPointerException.class, groups={"tck"})
 589     public void factory_parse_nullText() {
 590         LocalDate.parse((String) null);
 591     }
 592 
 593     //-----------------------------------------------------------------------
 594     // parse(DateTimeFormatter)
 595     //-----------------------------------------------------------------------
 596     @Test(groups={"tck"})
 597     public void factory_parse_formatter() {
 598         DateTimeFormatter f = DateTimeFormatters.pattern("y M d");
 599         LocalDate test = LocalDate.parse("2010 12 3", f);
 600         assertEquals(test, LocalDate.of(2010, 12, 3));
 601     }
 602 
 603     @Test(expectedExceptions=NullPointerException.class, groups={"tck"})
 604     public void factory_parse_formatter_nullText() {
 605         DateTimeFormatter f = DateTimeFormatters.pattern("y M d");
 606         LocalDate.parse((String) null, f);
 607     }
 608 
 609     @Test(expectedExceptions=NullPointerException.class, groups={"tck"})
 610     public void factory_parse_formatter_nullFormatter() {
 611         LocalDate.parse("ANY", null);
 612     }
 613 
 614     //-----------------------------------------------------------------------
 615     // get(TemporalField)
 616     //-----------------------------------------------------------------------
 617     @Test
 618     public void test_get_TemporalField() {
 619         LocalDate test = LocalDate.of(2008, 6, 30);
 620         assertEquals(test.get(ChronoField.YEAR), 2008);
 621         assertEquals(test.get(ChronoField.MONTH_OF_YEAR), 6);
 622         assertEquals(test.get(ChronoField.DAY_OF_MONTH), 30);
 623         assertEquals(test.get(ChronoField.DAY_OF_WEEK), 1);
 624         assertEquals(test.get(ChronoField.DAY_OF_YEAR), 182);
 625     }
 626 
 627     @Test
 628     public void test_getLong_TemporalField() {
 629         LocalDate test = LocalDate.of(2008, 6, 30);
 630         assertEquals(test.getLong(ChronoField.YEAR), 2008);
 631         assertEquals(test.getLong(ChronoField.MONTH_OF_YEAR), 6);
 632         assertEquals(test.getLong(ChronoField.DAY_OF_MONTH), 30);
 633         assertEquals(test.getLong(ChronoField.DAY_OF_WEEK), 1);
 634         assertEquals(test.getLong(ChronoField.DAY_OF_YEAR), 182);
 635     }
 636 
 637     //-----------------------------------------------------------------------
 638     // query(TemporalQuery)
 639     //-----------------------------------------------------------------------
 640     @Test
 641     public void test_query_chrono() {
 642         assertEquals(TEST_2007_07_15.query(Queries.chrono()), ISOChrono.INSTANCE);
 643         assertEquals(Queries.chrono().queryFrom(TEST_2007_07_15), ISOChrono.INSTANCE);
 644     }
 645 
 646     @Test
 647     public void test_query_zoneId() {
 648         assertEquals(TEST_2007_07_15.query(Queries.zoneId()), null);
 649         assertEquals(Queries.zoneId().queryFrom(TEST_2007_07_15), null);
 650     }
 651 
 652     @Test
 653     public void test_query_precision() {
 654         assertEquals(TEST_2007_07_15.query(Queries.precision()), ChronoUnit.DAYS);
 655         assertEquals(Queries.precision().queryFrom(TEST_2007_07_15), ChronoUnit.DAYS);
 656     }
 657 
 658     @Test
 659     public void test_query_offset() {
 660         assertEquals(TEST_2007_07_15.query(Queries.offset()), null);
 661         assertEquals(Queries.offset().queryFrom(TEST_2007_07_15), null);
 662     }
 663 
 664     @Test
 665     public void test_query_zone() {
 666         assertEquals(TEST_2007_07_15.query(Queries.zone()), null);
 667         assertEquals(Queries.zone().queryFrom(TEST_2007_07_15), null);
 668     }
 669 
 670     @Test(expectedExceptions=NullPointerException.class)
 671     public void test_query_null() {
 672         TEST_2007_07_15.query(null);
 673     }
 674 
 675     //-----------------------------------------------------------------------
 676     // get*()
 677     //-----------------------------------------------------------------------
 678     @DataProvider(name="sampleDates")
 679     Object[][] provider_sampleDates() {
 680         return new Object[][] {
 681             {2008, 7, 5},
 682             {2007, 7, 5},
 683             {2006, 7, 5},
 684             {2005, 7, 5},
 685             {2004, 1, 1},
 686             {-1, 1, 2},
 687         };


1612     public void test_minusDays_invalidTooLarge() {
1613         LocalDate.of(Year.MAX_VALUE, 12, 31).minusDays(-1);
1614     }
1615 
1616     @Test(expectedExceptions={DateTimeException.class}, groups={"tck"})
1617     public void test_minusDays_invalidTooSmall() {
1618         LocalDate.of(Year.MIN_VALUE, 1, 1).minusDays(1);
1619     }
1620 
1621     @Test(expectedExceptions=ArithmeticException.class, groups={"tck"})
1622     public void test_minusDays_overflowTooLarge() {
1623         LocalDate.of(Year.MAX_VALUE, 12, 31).minusDays(Long.MIN_VALUE);
1624     }
1625 
1626     @Test(expectedExceptions=ArithmeticException.class, groups={"tck"})
1627     public void test_minusDays_overflowTooSmall() {
1628         LocalDate.of(Year.MIN_VALUE, 1, 1).minusDays(Long.MAX_VALUE);
1629     }
1630 
1631     //-----------------------------------------------------------------------















































































































1632     // atTime()
1633     //-----------------------------------------------------------------------
1634     @Test(groups={"tck"})
1635     public void test_atTime_LocalTime() {
1636         LocalDate t = LocalDate.of(2008, 6, 30);
1637         assertEquals(t.atTime(LocalTime.of(11, 30)), LocalDateTime.of(2008, 6, 30, 11, 30));
1638     }
1639 
1640     @Test(expectedExceptions=NullPointerException.class, groups={"tck"})
1641     public void test_atTime_LocalTime_null() {
1642         LocalDate t = LocalDate.of(2008, 6, 30);
1643         t.atTime((LocalTime) null);
1644     }
1645 
1646     //-------------------------------------------------------------------------
1647     @Test(groups={"tck"})
1648     public void test_atTime_int_int() {
1649         LocalDate t = LocalDate.of(2008, 6, 30);
1650         assertEquals(t.atTime(11, 30), LocalDateTime.of(2008, 6, 30, 11, 30));
1651     }


1754 
1755     @Test(expectedExceptions=DateTimeException.class, groups={"tck"})
1756     public void test_atTime_int_int_int_int_secondTooBig() {
1757         LocalDate t = LocalDate.of(2008, 6, 30);
1758         t.atTime(11, 30, 60, 50);
1759     }
1760 
1761     @Test(expectedExceptions=DateTimeException.class, groups={"tck"})
1762     public void test_atTime_int_int_int_int_nanoTooSmall() {
1763         LocalDate t = LocalDate.of(2008, 6, 30);
1764         t.atTime(11, 30, 40, -1);
1765     }
1766 
1767     @Test(expectedExceptions=DateTimeException.class, groups={"tck"})
1768     public void test_atTime_int_int_int_int_nanoTooBig() {
1769         LocalDate t = LocalDate.of(2008, 6, 30);
1770         t.atTime(11, 30, 40, 1000000000);
1771     }
1772 
1773     //-----------------------------------------------------------------------
1774     // atOffset()
1775     //-----------------------------------------------------------------------
1776     @Test(groups={"tck"})
1777     public void test_atOffset() {
1778         LocalDate t = LocalDate.of(2008, 6, 30);
1779         assertEquals(t.atOffset(OFFSET_PTWO), OffsetDate.of(LocalDate.of(2008, 6, 30), OFFSET_PTWO));
1780     }
1781 
1782     @Test(expectedExceptions=NullPointerException.class, groups={"tck"})
1783     public void test_atOffset_nullZoneOffset() {
1784         LocalDate t = LocalDate.of(2008, 6, 30);
1785         t.atOffset((ZoneOffset) null);
1786     }
1787 
1788     //-----------------------------------------------------------------------
1789     // atStartOfDay()
1790     //-----------------------------------------------------------------------
1791     @Test(groups={"tck"})
1792     public void test_atStartOfDay() {
1793         LocalDate t = LocalDate.of(2008, 6, 30);
1794         assertEquals(t.atStartOfDay(ZONE_PARIS),
1795                 ZonedDateTime.of(LocalDateTime.of(2008, 6, 30, 0, 0), ZONE_PARIS));

1796     }
1797 
1798     @Test(groups={"tck"})
1799     public void test_atStartOfDay_dstGap() {
1800         LocalDate t = LocalDate.of(2007, 4, 1);
1801         assertEquals(t.atStartOfDay(ZONE_GAZA),
1802                 ZonedDateTime.of(LocalDateTime.of(2007, 4, 1, 1, 0), ZONE_GAZA));
1803     }
1804 
1805     @Test(expectedExceptions=NullPointerException.class, groups={"tck"})
1806     public void test_atStartOfDay_nullTimeZone() {

















1807         LocalDate t = LocalDate.of(2008, 6, 30);
1808         t.atStartOfDay((ZoneId) null);
1809     }
1810 
1811     //-----------------------------------------------------------------------
1812     // toEpochDay()
1813     //-----------------------------------------------------------------------
1814     @Test(groups={"tck"})
1815     public void test_toEpochDay() {
1816         long date_0000_01_01 = -678941 - 40587;
1817 
1818         LocalDate test = LocalDate.of(0, 1, 1);
1819         for (long i = date_0000_01_01; i < 700000; i++) {
1820             assertEquals(test.toEpochDay(), i);
1821             test = next(test);
1822         }
1823         test = LocalDate.of(0, 1, 1);
1824         for (long i = date_0000_01_01; i > -2000000; i--) {
1825             assertEquals(test.toEpochDay(), i);
1826             test = previous(test);


1988             {-9999, 12, 31, "-9999-12-31"},
1989             {10000, 1, 1, "+10000-01-01"},
1990             {-10000, 1, 1, "-10000-01-01"},
1991             {12345678, 1, 1, "+12345678-01-01"},
1992             {-12345678, 1, 1, "-12345678-01-01"},
1993         };
1994     }
1995 
1996     @Test(dataProvider="sampleToString", groups={"tck"})
1997     public void test_toString(int y, int m, int d, String expected) {
1998         LocalDate t = LocalDate.of(y, m, d);
1999         String str = t.toString();
2000         assertEquals(str, expected);
2001     }
2002 
2003     //-----------------------------------------------------------------------
2004     // toString(DateTimeFormatter)
2005     //-----------------------------------------------------------------------
2006     @Test(groups={"tck"})
2007     public void test_toString_formatter() {
2008         DateTimeFormatter f = DateTimeFormatters.pattern("y M d");
2009         String t = LocalDate.of(2010, 12, 3).toString(f);
2010         assertEquals(t, "2010 12 3");
2011     }
2012 
2013     @Test(expectedExceptions=NullPointerException.class, groups={"tck"})
2014     public void test_toString_formatter_null() {
2015         LocalDate.of(2010, 12, 3).toString(null);
2016     }
2017 
2018 }


  63 import static java.time.temporal.ChronoField.ALIGNED_DAY_OF_WEEK_IN_YEAR;
  64 import static java.time.temporal.ChronoField.ALIGNED_WEEK_OF_MONTH;
  65 import static java.time.temporal.ChronoField.ALIGNED_WEEK_OF_YEAR;
  66 import static java.time.temporal.ChronoField.DAY_OF_MONTH;
  67 import static java.time.temporal.ChronoField.DAY_OF_WEEK;
  68 import static java.time.temporal.ChronoField.DAY_OF_YEAR;
  69 import static java.time.temporal.ChronoField.EPOCH_DAY;
  70 import static java.time.temporal.ChronoField.EPOCH_MONTH;
  71 import static java.time.temporal.ChronoField.ERA;
  72 import static java.time.temporal.ChronoField.MONTH_OF_YEAR;
  73 import static java.time.temporal.ChronoField.YEAR;
  74 import static java.time.temporal.ChronoField.YEAR_OF_ERA;
  75 import static org.testng.Assert.assertEquals;
  76 import static org.testng.Assert.assertFalse;
  77 import static org.testng.Assert.assertNotNull;
  78 import static org.testng.Assert.assertSame;
  79 import static org.testng.Assert.assertTrue;
  80 
  81 import java.io.ByteArrayOutputStream;
  82 import java.io.DataOutputStream;





  83 import java.time.Clock;
  84 import java.time.DateTimeException;
  85 import java.time.DayOfWeek;
  86 import java.time.Instant;
  87 import java.time.LocalDate;
  88 import java.time.LocalDateTime;
  89 import java.time.LocalTime;
  90 import java.time.Month;
  91 import java.time.OffsetDateTime;
  92 import java.time.OffsetTime;
  93 import java.time.Period;
  94 import java.time.Year;
  95 import java.time.ZoneId;
  96 import java.time.ZoneOffset;
  97 import java.time.ZonedDateTime;
  98 import java.time.chrono.IsoChronology;
  99 import java.time.format.DateTimeFormatter;

 100 import java.time.format.DateTimeParseException;
 101 import java.time.temporal.ChronoField;
 102 import java.time.temporal.ChronoUnit;

 103 import java.time.temporal.JulianFields;

 104 import java.time.temporal.Queries;
 105 import java.time.temporal.Temporal;
 106 import java.time.temporal.TemporalAccessor;
 107 import java.time.temporal.TemporalAdjuster;
 108 import java.time.temporal.TemporalField;
 109 import java.time.temporal.TemporalQuery;
 110 import java.time.temporal.TemporalUnit;
 111 import java.util.ArrayList;
 112 import java.util.Arrays;
 113 import java.util.List;
 114 
 115 import org.testng.annotations.BeforeMethod;
 116 import org.testng.annotations.DataProvider;
 117 import org.testng.annotations.Test;
 118 import test.java.time.MockSimplePeriod;
 119 import test.java.time.temporal.MockFieldNoValue;
 120 
 121 /**
 122  * Test LocalDate.
 123  */
 124 @Test
 125 public class TCKLocalDate extends AbstractDateTimeTest {
 126 
 127     private static final ZoneOffset OFFSET_PONE = ZoneOffset.ofHours(1);
 128     private static final ZoneOffset OFFSET_PTWO = ZoneOffset.ofHours(2);
 129     private static final ZoneId ZONE_PARIS = ZoneId.of("Europe/Paris");
 130     private static final ZoneId ZONE_GAZA = ZoneId.of("Asia/Gaza");
 131 
 132     private LocalDate TEST_2007_07_15;
 133     private long MAX_VALID_EPOCHDAYS;


 578     @Test(expectedExceptions=DateTimeParseException.class, groups={"tck"})
 579     public void factory_parse_illegalValue() {
 580         LocalDate.parse("2008-06-32");
 581     }
 582 
 583     @Test(expectedExceptions=DateTimeParseException.class, groups={"tck"})
 584     public void factory_parse_invalidValue() {
 585         LocalDate.parse("2008-06-31");
 586     }
 587 
 588     @Test(expectedExceptions=NullPointerException.class, groups={"tck"})
 589     public void factory_parse_nullText() {
 590         LocalDate.parse((String) null);
 591     }
 592 
 593     //-----------------------------------------------------------------------
 594     // parse(DateTimeFormatter)
 595     //-----------------------------------------------------------------------
 596     @Test(groups={"tck"})
 597     public void factory_parse_formatter() {
 598         DateTimeFormatter f = DateTimeFormatter.ofPattern("y M d");
 599         LocalDate test = LocalDate.parse("2010 12 3", f);
 600         assertEquals(test, LocalDate.of(2010, 12, 3));
 601     }
 602 
 603     @Test(expectedExceptions=NullPointerException.class, groups={"tck"})
 604     public void factory_parse_formatter_nullText() {
 605         DateTimeFormatter f = DateTimeFormatter.ofPattern("y M d");
 606         LocalDate.parse((String) null, f);
 607     }
 608 
 609     @Test(expectedExceptions=NullPointerException.class, groups={"tck"})
 610     public void factory_parse_formatter_nullFormatter() {
 611         LocalDate.parse("ANY", null);
 612     }
 613 
 614     //-----------------------------------------------------------------------
 615     // get(TemporalField)
 616     //-----------------------------------------------------------------------
 617     @Test
 618     public void test_get_TemporalField() {
 619         LocalDate test = LocalDate.of(2008, 6, 30);
 620         assertEquals(test.get(ChronoField.YEAR), 2008);
 621         assertEquals(test.get(ChronoField.MONTH_OF_YEAR), 6);
 622         assertEquals(test.get(ChronoField.DAY_OF_MONTH), 30);
 623         assertEquals(test.get(ChronoField.DAY_OF_WEEK), 1);
 624         assertEquals(test.get(ChronoField.DAY_OF_YEAR), 182);
 625     }
 626 
 627     @Test
 628     public void test_getLong_TemporalField() {
 629         LocalDate test = LocalDate.of(2008, 6, 30);
 630         assertEquals(test.getLong(ChronoField.YEAR), 2008);
 631         assertEquals(test.getLong(ChronoField.MONTH_OF_YEAR), 6);
 632         assertEquals(test.getLong(ChronoField.DAY_OF_MONTH), 30);
 633         assertEquals(test.getLong(ChronoField.DAY_OF_WEEK), 1);
 634         assertEquals(test.getLong(ChronoField.DAY_OF_YEAR), 182);
 635     }
 636 
 637     //-----------------------------------------------------------------------
 638     // query(TemporalQuery)
 639     //-----------------------------------------------------------------------
 640     @DataProvider(name="query")
 641     Object[][] data_query() {
 642         return new Object[][] {
 643                 {TEST_2007_07_15, Queries.chronology(), IsoChronology.INSTANCE},
 644                 {TEST_2007_07_15, Queries.zoneId(), null},
 645                 {TEST_2007_07_15, Queries.precision(), ChronoUnit.DAYS},
 646                 {TEST_2007_07_15, Queries.zone(), null},
 647                 {TEST_2007_07_15, Queries.offset(), null},
 648                 {TEST_2007_07_15, Queries.localDate(), TEST_2007_07_15},
 649                 {TEST_2007_07_15, Queries.localTime(), null},
 650         };





 651     }
 652 
 653     @Test(dataProvider="query")
 654     public <T> void test_query(TemporalAccessor temporal, TemporalQuery<T> query, T expected) {
 655         assertEquals(temporal.query(query), expected);

 656     }
 657 
 658     @Test(dataProvider="query")
 659     public <T> void test_queryFrom(TemporalAccessor temporal, TemporalQuery<T> query, T expected) {
 660         assertEquals(query.queryFrom(temporal), expected);

 661     }
 662 
 663     @Test(expectedExceptions=NullPointerException.class)
 664     public void test_query_null() {
 665         TEST_2007_07_15.query(null);
 666     }
 667 
 668     //-----------------------------------------------------------------------
 669     // get*()
 670     //-----------------------------------------------------------------------
 671     @DataProvider(name="sampleDates")
 672     Object[][] provider_sampleDates() {
 673         return new Object[][] {
 674             {2008, 7, 5},
 675             {2007, 7, 5},
 676             {2006, 7, 5},
 677             {2005, 7, 5},
 678             {2004, 1, 1},
 679             {-1, 1, 2},
 680         };


1605     public void test_minusDays_invalidTooLarge() {
1606         LocalDate.of(Year.MAX_VALUE, 12, 31).minusDays(-1);
1607     }
1608 
1609     @Test(expectedExceptions={DateTimeException.class}, groups={"tck"})
1610     public void test_minusDays_invalidTooSmall() {
1611         LocalDate.of(Year.MIN_VALUE, 1, 1).minusDays(1);
1612     }
1613 
1614     @Test(expectedExceptions=ArithmeticException.class, groups={"tck"})
1615     public void test_minusDays_overflowTooLarge() {
1616         LocalDate.of(Year.MAX_VALUE, 12, 31).minusDays(Long.MIN_VALUE);
1617     }
1618 
1619     @Test(expectedExceptions=ArithmeticException.class, groups={"tck"})
1620     public void test_minusDays_overflowTooSmall() {
1621         LocalDate.of(Year.MIN_VALUE, 1, 1).minusDays(Long.MAX_VALUE);
1622     }
1623 
1624     //-----------------------------------------------------------------------
1625     // periodUntil(ChronoLocalDate)
1626     //-----------------------------------------------------------------------
1627     @DataProvider(name="periodUntil")
1628     Object[][] data_periodUntil() {
1629         return new Object[][] {
1630                 {2010, 1, 1, 2010, 1, 1, 0, 0, 0},
1631                 {2010, 1, 1, 2010, 1, 2, 0, 0, 1},
1632                 {2010, 1, 1, 2010, 1, 31, 0, 0, 30},
1633                 {2010, 1, 1, 2010, 2, 1, 0, 1, 0},
1634                 {2010, 1, 1, 2010, 2, 28, 0, 1, 27},
1635                 {2010, 1, 1, 2010, 3, 1, 0, 2, 0},
1636                 {2010, 1, 1, 2010, 12, 31, 0, 11, 30},
1637                 {2010, 1, 1, 2011, 1, 1, 1, 0, 0},
1638                 {2010, 1, 1, 2011, 12, 31, 1, 11, 30},
1639                 {2010, 1, 1, 2012, 1, 1, 2, 0, 0},
1640 
1641                 {2010, 1, 10, 2010, 1, 1, 0, 0, -9},
1642                 {2010, 1, 10, 2010, 1, 2, 0, 0, -8},
1643                 {2010, 1, 10, 2010, 1, 9, 0, 0, -1},
1644                 {2010, 1, 10, 2010, 1, 10, 0, 0, 0},
1645                 {2010, 1, 10, 2010, 1, 11, 0, 0, 1},
1646                 {2010, 1, 10, 2010, 1, 31, 0, 0, 21},
1647                 {2010, 1, 10, 2010, 2, 1, 0, 0, 22},
1648                 {2010, 1, 10, 2010, 2, 9, 0, 0, 30},
1649                 {2010, 1, 10, 2010, 2, 10, 0, 1, 0},
1650                 {2010, 1, 10, 2010, 2, 28, 0, 1, 18},
1651                 {2010, 1, 10, 2010, 3, 1, 0, 1, 19},
1652                 {2010, 1, 10, 2010, 3, 9, 0, 1, 27},
1653                 {2010, 1, 10, 2010, 3, 10, 0, 2, 0},
1654                 {2010, 1, 10, 2010, 12, 31, 0, 11, 21},
1655                 {2010, 1, 10, 2011, 1, 1, 0, 11, 22},
1656                 {2010, 1, 10, 2011, 1, 9, 0, 11, 30},
1657                 {2010, 1, 10, 2011, 1, 10, 1, 0, 0},
1658 
1659                 {2010, 3, 30, 2011, 5, 1, 1, 1, 1},
1660                 {2010, 4, 30, 2011, 5, 1, 1, 0, 1},
1661 
1662                 {2010, 2, 28, 2012, 2, 27, 1, 11, 30},
1663                 {2010, 2, 28, 2012, 2, 28, 2, 0, 0},
1664                 {2010, 2, 28, 2012, 2, 29, 2, 0, 1},
1665 
1666                 {2012, 2, 28, 2014, 2, 27, 1, 11, 30},
1667                 {2012, 2, 28, 2014, 2, 28, 2, 0, 0},
1668                 {2012, 2, 28, 2014, 3, 1, 2, 0, 1},
1669 
1670                 {2012, 2, 29, 2014, 2, 28, 1, 11, 30},
1671                 {2012, 2, 29, 2014, 3, 1, 2, 0, 1},
1672                 {2012, 2, 29, 2014, 3, 2, 2, 0, 2},
1673 
1674                 {2012, 2, 29, 2016, 2, 28, 3, 11, 30},
1675                 {2012, 2, 29, 2016, 2, 29, 4, 0, 0},
1676                 {2012, 2, 29, 2016, 3, 1, 4, 0, 1},
1677 
1678                 {2010, 1, 1, 2009, 12, 31, 0, 0, -1},
1679                 {2010, 1, 1, 2009, 12, 30, 0, 0, -2},
1680                 {2010, 1, 1, 2009, 12, 2, 0, 0, -30},
1681                 {2010, 1, 1, 2009, 12, 1, 0, -1, 0},
1682                 {2010, 1, 1, 2009, 11, 30, 0, -1, -1},
1683                 {2010, 1, 1, 2009, 11, 2, 0, -1, -29},
1684                 {2010, 1, 1, 2009, 11, 1, 0, -2, 0},
1685                 {2010, 1, 1, 2009, 1, 2, 0, -11, -30},
1686                 {2010, 1, 1, 2009, 1, 1, -1, 0, 0},
1687 
1688                 {2010, 1, 15, 2010, 1, 15, 0, 0, 0},
1689                 {2010, 1, 15, 2010, 1, 14, 0, 0, -1},
1690                 {2010, 1, 15, 2010, 1, 1, 0, 0, -14},
1691                 {2010, 1, 15, 2009, 12, 31, 0, 0, -15},
1692                 {2010, 1, 15, 2009, 12, 16, 0, 0, -30},
1693                 {2010, 1, 15, 2009, 12, 15, 0, -1, 0},
1694                 {2010, 1, 15, 2009, 12, 14, 0, -1, -1},
1695 
1696                 {2010, 2, 28, 2009, 3, 1, 0, -11, -27},
1697                 {2010, 2, 28, 2009, 2, 28, -1, 0, 0},
1698                 {2010, 2, 28, 2009, 2, 27, -1, 0, -1},
1699 
1700                 {2010, 2, 28, 2008, 2, 29, -1, -11, -28},
1701                 {2010, 2, 28, 2008, 2, 28, -2, 0, 0},
1702                 {2010, 2, 28, 2008, 2, 27, -2, 0, -1},
1703 
1704                 {2012, 2, 29, 2009, 3, 1, -2, -11, -28},
1705                 {2012, 2, 29, 2009, 2, 28, -3, 0, -1},
1706                 {2012, 2, 29, 2009, 2, 27, -3, 0, -2},
1707 
1708                 {2012, 2, 29, 2008, 3, 1, -3, -11, -28},
1709                 {2012, 2, 29, 2008, 2, 29, -4, 0, 0},
1710                 {2012, 2, 29, 2008, 2, 28, -4, 0, -1},
1711         };
1712     }
1713 
1714     @Test(dataProvider="periodUntil")
1715     public void test_periodUntil_LocalDate(int y1, int m1, int d1, int y2, int m2, int d2, int ye, int me, int de) {
1716         LocalDate start = LocalDate.of(y1, m1, d1);
1717         LocalDate end = LocalDate.of(y2, m2, d2);
1718         Period test = start.periodUntil(end);
1719         assertEquals(test.getYears(), ye);
1720         assertEquals(test.getMonths(), me);
1721         assertEquals(test.getDays(), de);
1722     }
1723 
1724     @Test
1725     public void test_periodUntil_LocalDate_max() {
1726         int years = Math.toIntExact((long) Year.MAX_VALUE - (long) Year.MIN_VALUE);
1727         assertEquals(LocalDate.MIN.periodUntil(LocalDate.MAX), Period.of(years, 11, 30));
1728     }
1729 
1730     @Test(expectedExceptions=NullPointerException.class)
1731     public void test_periodUntil_LocalDate_null() {
1732         TEST_2007_07_15.periodUntil(null);
1733     }
1734 
1735     //-----------------------------------------------------------------------
1736     // atTime()
1737     //-----------------------------------------------------------------------
1738     @Test(groups={"tck"})
1739     public void test_atTime_LocalTime() {
1740         LocalDate t = LocalDate.of(2008, 6, 30);
1741         assertEquals(t.atTime(LocalTime.of(11, 30)), LocalDateTime.of(2008, 6, 30, 11, 30));
1742     }
1743 
1744     @Test(expectedExceptions=NullPointerException.class, groups={"tck"})
1745     public void test_atTime_LocalTime_null() {
1746         LocalDate t = LocalDate.of(2008, 6, 30);
1747         t.atTime((LocalTime) null);
1748     }
1749 
1750     //-------------------------------------------------------------------------
1751     @Test(groups={"tck"})
1752     public void test_atTime_int_int() {
1753         LocalDate t = LocalDate.of(2008, 6, 30);
1754         assertEquals(t.atTime(11, 30), LocalDateTime.of(2008, 6, 30, 11, 30));
1755     }


1858 
1859     @Test(expectedExceptions=DateTimeException.class, groups={"tck"})
1860     public void test_atTime_int_int_int_int_secondTooBig() {
1861         LocalDate t = LocalDate.of(2008, 6, 30);
1862         t.atTime(11, 30, 60, 50);
1863     }
1864 
1865     @Test(expectedExceptions=DateTimeException.class, groups={"tck"})
1866     public void test_atTime_int_int_int_int_nanoTooSmall() {
1867         LocalDate t = LocalDate.of(2008, 6, 30);
1868         t.atTime(11, 30, 40, -1);
1869     }
1870 
1871     @Test(expectedExceptions=DateTimeException.class, groups={"tck"})
1872     public void test_atTime_int_int_int_int_nanoTooBig() {
1873         LocalDate t = LocalDate.of(2008, 6, 30);
1874         t.atTime(11, 30, 40, 1000000000);
1875     }
1876 
1877     //-----------------------------------------------------------------------


1878     @Test(groups={"tck"})
1879     public void test_atTime_OffsetTime() {
1880         LocalDate t = LocalDate.of(2008, 6, 30);
1881         assertEquals(t.atTime(OffsetTime.of(11, 30, 0, 0, OFFSET_PONE)), OffsetDateTime.of(2008, 6, 30, 11, 30, 0, 0, OFFSET_PONE));
1882     }
1883 
1884     @Test(expectedExceptions=NullPointerException.class, groups={"tck"})
1885     public void test_atTime_OffsetTime_null() {
1886         LocalDate t = LocalDate.of(2008, 6, 30);
1887         t.atTime((OffsetTime) null);
1888     }
1889 
1890     //-----------------------------------------------------------------------
1891     // atStartOfDay()
1892     //-----------------------------------------------------------------------
1893     @DataProvider(name="atStartOfDay")
1894     Object[][] data_atStartOfDay() {
1895         return new Object[][] {
1896                 {LocalDate.of(2008, 6, 30), LocalDateTime.of(2008, 6, 30, 0, 0)},
1897                 {LocalDate.of(-12, 6, 30), LocalDateTime.of(-12, 6, 30, 0, 0)},
1898         };
1899     }
1900 
1901     @Test(dataProvider="atStartOfDay")
1902     public void test_atStartOfDay(LocalDate test, LocalDateTime expected) {
1903         assertEquals(test.atStartOfDay(), expected);


1904     }
1905 
1906     //-----------------------------------------------------------------------
1907     // atStartOfDay(ZoneId)
1908     //-----------------------------------------------------------------------
1909     @DataProvider(name="atStartOfDayZoneId")
1910     Object[][] data_atStartOfDayZoneId() {
1911         return new Object[][] {
1912                 {LocalDate.of(2008, 6, 30), ZONE_PARIS, ZonedDateTime.of(LocalDateTime.of(2008, 6, 30, 0, 0), ZONE_PARIS)},
1913                 {LocalDate.of(2008, 6, 30), OFFSET_PONE, ZonedDateTime.of(LocalDateTime.of(2008, 6, 30, 0, 0), OFFSET_PONE)},
1914                 {LocalDate.of(2007, 4, 1), ZONE_GAZA, ZonedDateTime.of(LocalDateTime.of(2007, 4, 1, 1, 0), ZONE_GAZA)},
1915         };
1916     }
1917 
1918     @Test(dataProvider="atStartOfDayZoneId")
1919     public void test_atStartOfDay_ZoneId(LocalDate test, ZoneId zone, ZonedDateTime expected) {
1920         assertEquals(test.atStartOfDay(zone), expected);
1921     }
1922 
1923     @Test(expectedExceptions=NullPointerException.class)
1924     public void test_atStartOfDay_ZoneId_null() {
1925         LocalDate t = LocalDate.of(2008, 6, 30);
1926         t.atStartOfDay((ZoneId) null);
1927     }
1928 
1929     //-----------------------------------------------------------------------
1930     // toEpochDay()
1931     //-----------------------------------------------------------------------
1932     @Test(groups={"tck"})
1933     public void test_toEpochDay() {
1934         long date_0000_01_01 = -678941 - 40587;
1935 
1936         LocalDate test = LocalDate.of(0, 1, 1);
1937         for (long i = date_0000_01_01; i < 700000; i++) {
1938             assertEquals(test.toEpochDay(), i);
1939             test = next(test);
1940         }
1941         test = LocalDate.of(0, 1, 1);
1942         for (long i = date_0000_01_01; i > -2000000; i--) {
1943             assertEquals(test.toEpochDay(), i);
1944             test = previous(test);


2106             {-9999, 12, 31, "-9999-12-31"},
2107             {10000, 1, 1, "+10000-01-01"},
2108             {-10000, 1, 1, "-10000-01-01"},
2109             {12345678, 1, 1, "+12345678-01-01"},
2110             {-12345678, 1, 1, "-12345678-01-01"},
2111         };
2112     }
2113 
2114     @Test(dataProvider="sampleToString", groups={"tck"})
2115     public void test_toString(int y, int m, int d, String expected) {
2116         LocalDate t = LocalDate.of(y, m, d);
2117         String str = t.toString();
2118         assertEquals(str, expected);
2119     }
2120 
2121     //-----------------------------------------------------------------------
2122     // toString(DateTimeFormatter)
2123     //-----------------------------------------------------------------------
2124     @Test(groups={"tck"})
2125     public void test_toString_formatter() {
2126         DateTimeFormatter f = DateTimeFormatter.ofPattern("y M d");
2127         String t = LocalDate.of(2010, 12, 3).toString(f);
2128         assertEquals(t, "2010 12 3");
2129     }
2130 
2131     @Test(expectedExceptions=NullPointerException.class, groups={"tck"})
2132     public void test_toString_formatter_null() {
2133         LocalDate.of(2010, 12, 3).toString(null);
2134     }
2135 
2136 }