test/java/time/test/java/time/temporal/TestChronoUnit.java

Print this page




  89             {date(1939, SEPTEMBER, 2), date(1939, SEPTEMBER, 1), 0},
  90             {date(1939, SEPTEMBER, 2), date(1939, SEPTEMBER, 2), 0},
  91             {date(1939, SEPTEMBER, 2), date(1939, SEPTEMBER, 3), 0},
  92 
  93             {date(1939, SEPTEMBER, 2), date(1940, SEPTEMBER, 1), 0},
  94             {date(1939, SEPTEMBER, 2), date(1940, SEPTEMBER, 2), 1},
  95             {date(1939, SEPTEMBER, 2), date(1940, SEPTEMBER, 3), 1},
  96 
  97             {date(1939, SEPTEMBER, 2), date(1938, SEPTEMBER, 1), -1},
  98             {date(1939, SEPTEMBER, 2), date(1938, SEPTEMBER, 2), -1},
  99             {date(1939, SEPTEMBER, 2), date(1938, SEPTEMBER, 3), 0},
 100 
 101             {date(1939, SEPTEMBER, 2), date(1945, SEPTEMBER, 3), 6},
 102             {date(1939, SEPTEMBER, 2), date(1945, OCTOBER, 3), 6},
 103             {date(1939, SEPTEMBER, 2), date(1945, AUGUST, 3), 5},
 104         };
 105     }
 106 
 107     @Test(dataProvider = "yearsBetween")
 108     public void test_yearsBetween(LocalDate start, LocalDate end, long expected) {
 109         assertEquals(YEARS.between(start, end).getAmount(), expected);
 110         assertEquals(YEARS.between(start, end).getUnit(), YEARS);
 111     }
 112 
 113     @Test(dataProvider = "yearsBetween")
 114     public void test_yearsBetweenReversed(LocalDate start, LocalDate end, long expected) {
 115         assertEquals(YEARS.between(end, start).getAmount(), -expected);
 116         assertEquals(YEARS.between(end, start).getUnit(), YEARS);
 117     }
 118 
 119     @Test(dataProvider = "yearsBetween")
 120     public void test_yearsBetween_LocalDateTimeSameTime(LocalDate start, LocalDate end, long expected) {
 121         assertEquals(YEARS.between(start.atTime(12, 30), end.atTime(12, 30)).getAmount(), expected);
 122     }
 123 
 124     @Test(dataProvider = "yearsBetween")
 125     public void test_yearsBetween_LocalDateTimeLaterTime(LocalDate start, LocalDate end, long expected) {
 126         assertEquals(YEARS.between(start.atTime(12, 30), end.atTime(12, 31)).getAmount(), expected);
 127     }
 128 
 129     @Test(dataProvider = "yearsBetween")
 130     public void test_yearsBetween_ZonedDateSameOffset(LocalDate start, LocalDate end, long expected) {
 131         assertEquals(YEARS.between(start.atStartOfDay(ZoneOffset.ofHours(2)), end.atStartOfDay(ZoneOffset.ofHours(2))).getAmount(), expected);
 132     }
 133 
 134     @Test(dataProvider = "yearsBetween")
 135     public void test_yearsBetween_ZonedDateLaterOffset(LocalDate start, LocalDate end, long expected) {
 136         // +01:00 is later than +02:00
 137         assertEquals(YEARS.between(start.atStartOfDay(ZoneOffset.ofHours(2)), end.atStartOfDay(ZoneOffset.ofHours(1))).getAmount(), expected);
 138     }
 139 
 140     //-----------------------------------------------------------------------
 141     @DataProvider(name = "monthsBetween")
 142     Object[][] data_monthsBetween() {
 143         return new Object[][] {
 144             {date(2012, JULY, 2), date(2012, JULY, 1), 0},
 145             {date(2012, JULY, 2), date(2012, JULY, 2), 0},
 146             {date(2012, JULY, 2), date(2012, JULY, 3), 0},
 147 
 148             {date(2012, JULY, 2), date(2012, AUGUST, 1), 0},
 149             {date(2012, JULY, 2), date(2012, AUGUST, 2), 1},
 150             {date(2012, JULY, 2), date(2012, AUGUST, 3), 1},
 151 
 152             {date(2012, JULY, 2), date(2012, SEPTEMBER, 1), 1},
 153             {date(2012, JULY, 2), date(2012, SEPTEMBER, 2), 2},
 154             {date(2012, JULY, 2), date(2012, SEPTEMBER, 3), 2},
 155 
 156             {date(2012, JULY, 2), date(2012, JUNE, 1), -1},
 157             {date(2012, JULY, 2), date(2012, JUNE, 2), -1},
 158             {date(2012, JULY, 2), date(2012, JUNE, 3), 0},
 159 
 160             {date(2012, FEBRUARY, 27), date(2012, MARCH, 26), 0},
 161             {date(2012, FEBRUARY, 27), date(2012, MARCH, 27), 1},
 162             {date(2012, FEBRUARY, 27), date(2012, MARCH, 28), 1},
 163 
 164             {date(2012, FEBRUARY, 28), date(2012, MARCH, 27), 0},
 165             {date(2012, FEBRUARY, 28), date(2012, MARCH, 28), 1},
 166             {date(2012, FEBRUARY, 28), date(2012, MARCH, 29), 1},
 167 
 168             {date(2012, FEBRUARY, 29), date(2012, MARCH, 28), 0},
 169             {date(2012, FEBRUARY, 29), date(2012, MARCH, 29), 1},
 170             {date(2012, FEBRUARY, 29), date(2012, MARCH, 30), 1},
 171         };
 172     }
 173 
 174     @Test(dataProvider = "monthsBetween")
 175     public void test_monthsBetween(LocalDate start, LocalDate end, long expected) {
 176         assertEquals(MONTHS.between(start, end).getAmount(), expected);
 177         assertEquals(MONTHS.between(start, end).getUnit(), MONTHS);
 178     }
 179 
 180     @Test(dataProvider = "monthsBetween")
 181     public void test_monthsBetweenReversed(LocalDate start, LocalDate end, long expected) {
 182         assertEquals(MONTHS.between(end, start).getAmount(), -expected);
 183         assertEquals(MONTHS.between(end, start).getUnit(), MONTHS);
 184     }
 185 
 186     @Test(dataProvider = "monthsBetween")
 187     public void test_monthsBetween_LocalDateTimeSameTime(LocalDate start, LocalDate end, long expected) {
 188         assertEquals(MONTHS.between(start.atTime(12, 30), end.atTime(12, 30)).getAmount(), expected);
 189     }
 190 
 191     @Test(dataProvider = "monthsBetween")
 192     public void test_monthsBetween_LocalDateTimeLaterTime(LocalDate start, LocalDate end, long expected) {
 193         assertEquals(MONTHS.between(start.atTime(12, 30), end.atTime(12, 31)).getAmount(), expected);
 194     }
 195 
 196     @Test(dataProvider = "monthsBetween")
 197     public void test_monthsBetween_ZonedDateSameOffset(LocalDate start, LocalDate end, long expected) {
 198         assertEquals(MONTHS.between(start.atStartOfDay(ZoneOffset.ofHours(2)), end.atStartOfDay(ZoneOffset.ofHours(2))).getAmount(), expected);
 199     }
 200 
 201     @Test(dataProvider = "monthsBetween")
 202     public void test_monthsBetween_ZonedDateLaterOffset(LocalDate start, LocalDate end, long expected) {
 203         // +01:00 is later than +02:00
 204         assertEquals(MONTHS.between(start.atStartOfDay(ZoneOffset.ofHours(2)), end.atStartOfDay(ZoneOffset.ofHours(1))).getAmount(), expected);
 205     }
 206 
 207     //-----------------------------------------------------------------------
 208     @DataProvider(name = "weeksBetween")
 209     Object[][] data_weeksBetween() {
 210         return new Object[][] {
 211             {date(2012, JULY, 2), date(2012, JUNE, 25), -1},
 212             {date(2012, JULY, 2), date(2012, JUNE, 26), 0},
 213             {date(2012, JULY, 2), date(2012, JULY, 2), 0},
 214             {date(2012, JULY, 2), date(2012, JULY, 8), 0},
 215             {date(2012, JULY, 2), date(2012, JULY, 9), 1},
 216 
 217             {date(2012, FEBRUARY, 28), date(2012, FEBRUARY, 21), -1},
 218             {date(2012, FEBRUARY, 28), date(2012, FEBRUARY, 22), 0},
 219             {date(2012, FEBRUARY, 28), date(2012, FEBRUARY, 28), 0},
 220             {date(2012, FEBRUARY, 28), date(2012, FEBRUARY, 29), 0},
 221             {date(2012, FEBRUARY, 28), date(2012, MARCH, 1), 0},
 222             {date(2012, FEBRUARY, 28), date(2012, MARCH, 5), 0},
 223             {date(2012, FEBRUARY, 28), date(2012, MARCH, 6), 1},
 224 
 225             {date(2012, FEBRUARY, 29), date(2012, FEBRUARY, 22), -1},
 226             {date(2012, FEBRUARY, 29), date(2012, FEBRUARY, 23), 0},
 227             {date(2012, FEBRUARY, 29), date(2012, FEBRUARY, 28), 0},
 228             {date(2012, FEBRUARY, 29), date(2012, FEBRUARY, 29), 0},
 229             {date(2012, FEBRUARY, 29), date(2012, MARCH, 1), 0},
 230             {date(2012, FEBRUARY, 29), date(2012, MARCH, 6), 0},
 231             {date(2012, FEBRUARY, 29), date(2012, MARCH, 7), 1},
 232         };
 233     }
 234 
 235     @Test(dataProvider = "weeksBetween")
 236     public void test_weeksBetween(LocalDate start, LocalDate end, long expected) {
 237         assertEquals(WEEKS.between(start, end).getAmount(), expected);
 238         assertEquals(WEEKS.between(start, end).getUnit(), WEEKS);
 239     }
 240 
 241     @Test(dataProvider = "weeksBetween")
 242     public void test_weeksBetweenReversed(LocalDate start, LocalDate end, long expected) {
 243         assertEquals(WEEKS.between(end, start).getAmount(), -expected);
 244         assertEquals(WEEKS.between(end, start).getUnit(), WEEKS);
 245     }
 246 
 247     //-----------------------------------------------------------------------
 248     @DataProvider(name = "daysBetween")
 249     Object[][] data_daysBetween() {
 250         return new Object[][] {
 251             {date(2012, JULY, 2), date(2012, JULY, 1), -1},
 252             {date(2012, JULY, 2), date(2012, JULY, 2), 0},
 253             {date(2012, JULY, 2), date(2012, JULY, 3), 1},
 254 
 255             {date(2012, FEBRUARY, 28), date(2012, FEBRUARY, 27), -1},
 256             {date(2012, FEBRUARY, 28), date(2012, FEBRUARY, 28), 0},
 257             {date(2012, FEBRUARY, 28), date(2012, FEBRUARY, 29), 1},
 258             {date(2012, FEBRUARY, 28), date(2012, MARCH, 1), 2},
 259 
 260             {date(2012, FEBRUARY, 29), date(2012, FEBRUARY, 27), -2},
 261             {date(2012, FEBRUARY, 29), date(2012, FEBRUARY, 28), -1},
 262             {date(2012, FEBRUARY, 29), date(2012, FEBRUARY, 29), 0},
 263             {date(2012, FEBRUARY, 29), date(2012, MARCH, 1), 1},
 264 
 265             {date(2012, MARCH, 1), date(2012, FEBRUARY, 27), -3},
 266             {date(2012, MARCH, 1), date(2012, FEBRUARY, 28), -2},
 267             {date(2012, MARCH, 1), date(2012, FEBRUARY, 29), -1},
 268             {date(2012, MARCH, 1), date(2012, MARCH, 1), 0},
 269             {date(2012, MARCH, 1), date(2012, MARCH, 2), 1},
 270 
 271             {date(2012, MARCH, 1), date(2013, FEBRUARY, 28), 364},
 272             {date(2012, MARCH, 1), date(2013, MARCH, 1), 365},
 273 
 274             {date(2011, MARCH, 1), date(2012, FEBRUARY, 28), 364},
 275             {date(2011, MARCH, 1), date(2012, FEBRUARY, 29), 365},
 276             {date(2011, MARCH, 1), date(2012, MARCH, 1), 366},
 277         };
 278     }
 279 
 280     @Test(dataProvider = "daysBetween")
 281     public void test_daysBetween(LocalDate start, LocalDate end, long expected) {
 282         assertEquals(DAYS.between(start, end).getAmount(), expected);
 283         assertEquals(DAYS.between(start, end).getUnit(), DAYS);
 284     }
 285 
 286     @Test(dataProvider = "daysBetween")
 287     public void test_daysBetweenReversed(LocalDate start, LocalDate end, long expected) {
 288         assertEquals(DAYS.between(end, start).getAmount(), -expected);
 289         assertEquals(DAYS.between(end, start).getUnit(), DAYS);
 290     }
 291 
 292     @Test(dataProvider = "daysBetween")
 293     public void test_daysBetween_LocalDateTimeSameTime(LocalDate start, LocalDate end, long expected) {
 294         assertEquals(DAYS.between(start.atTime(12, 30), end.atTime(12, 30)).getAmount(), expected);
 295     }
 296 
 297     @Test(dataProvider = "daysBetween")
 298     public void test_daysBetween_LocalDateTimeLaterTime(LocalDate start, LocalDate end, long expected) {
 299         assertEquals(DAYS.between(start.atTime(12, 30), end.atTime(12, 31)).getAmount(), expected);
 300     }
 301 
 302     @Test(dataProvider = "daysBetween")
 303     public void test_daysBetween_ZonedDateSameOffset(LocalDate start, LocalDate end, long expected) {
 304         assertEquals(DAYS.between(start.atStartOfDay(ZoneOffset.ofHours(2)), end.atStartOfDay(ZoneOffset.ofHours(2))).getAmount(), expected);
 305     }
 306 
 307     @Test(dataProvider = "daysBetween")
 308     public void test_daysBetween_ZonedDateLaterOffset(LocalDate start, LocalDate end, long expected) {
 309         // +01:00 is later than +02:00
 310         assertEquals(DAYS.between(start.atStartOfDay(ZoneOffset.ofHours(2)), end.atStartOfDay(ZoneOffset.ofHours(1))).getAmount(), expected);
 311     }
 312 
 313     //-----------------------------------------------------------------------
 314     private static LocalDate date(int year, Month month, int dom) {
 315         return LocalDate.of(year, month, dom);
 316     }
 317 
 318 }


  89             {date(1939, SEPTEMBER, 2), date(1939, SEPTEMBER, 1), 0},
  90             {date(1939, SEPTEMBER, 2), date(1939, SEPTEMBER, 2), 0},
  91             {date(1939, SEPTEMBER, 2), date(1939, SEPTEMBER, 3), 0},
  92 
  93             {date(1939, SEPTEMBER, 2), date(1940, SEPTEMBER, 1), 0},
  94             {date(1939, SEPTEMBER, 2), date(1940, SEPTEMBER, 2), 1},
  95             {date(1939, SEPTEMBER, 2), date(1940, SEPTEMBER, 3), 1},
  96 
  97             {date(1939, SEPTEMBER, 2), date(1938, SEPTEMBER, 1), -1},
  98             {date(1939, SEPTEMBER, 2), date(1938, SEPTEMBER, 2), -1},
  99             {date(1939, SEPTEMBER, 2), date(1938, SEPTEMBER, 3), 0},
 100 
 101             {date(1939, SEPTEMBER, 2), date(1945, SEPTEMBER, 3), 6},
 102             {date(1939, SEPTEMBER, 2), date(1945, OCTOBER, 3), 6},
 103             {date(1939, SEPTEMBER, 2), date(1945, AUGUST, 3), 5},
 104         };
 105     }
 106 
 107     @Test(dataProvider = "yearsBetween")
 108     public void test_yearsBetween(LocalDate start, LocalDate end, long expected) {
 109         assertEquals(YEARS.between(start, end), expected);

 110     }
 111 
 112     @Test(dataProvider = "yearsBetween")
 113     public void test_yearsBetweenReversed(LocalDate start, LocalDate end, long expected) {
 114         assertEquals(YEARS.between(end, start), -expected);

 115     }
 116 
 117     @Test(dataProvider = "yearsBetween")
 118     public void test_yearsBetween_LocalDateTimeSameTime(LocalDate start, LocalDate end, long expected) {
 119         assertEquals(YEARS.between(start.atTime(12, 30), end.atTime(12, 30)), expected);
 120     }
 121 
 122     @Test(dataProvider = "yearsBetween")
 123     public void test_yearsBetween_LocalDateTimeLaterTime(LocalDate start, LocalDate end, long expected) {
 124         assertEquals(YEARS.between(start.atTime(12, 30), end.atTime(12, 31)), expected);
 125     }
 126 
 127     @Test(dataProvider = "yearsBetween")
 128     public void test_yearsBetween_ZonedDateSameOffset(LocalDate start, LocalDate end, long expected) {
 129         assertEquals(YEARS.between(start.atStartOfDay(ZoneOffset.ofHours(2)), end.atStartOfDay(ZoneOffset.ofHours(2))), expected);
 130     }
 131 
 132     @Test(dataProvider = "yearsBetween")
 133     public void test_yearsBetween_ZonedDateLaterOffset(LocalDate start, LocalDate end, long expected) {
 134         // +01:00 is later than +02:00
 135         assertEquals(YEARS.between(start.atStartOfDay(ZoneOffset.ofHours(2)), end.atStartOfDay(ZoneOffset.ofHours(1))), expected);
 136     }
 137 
 138     //-----------------------------------------------------------------------
 139     @DataProvider(name = "monthsBetween")
 140     Object[][] data_monthsBetween() {
 141         return new Object[][] {
 142             {date(2012, JULY, 2), date(2012, JULY, 1), 0},
 143             {date(2012, JULY, 2), date(2012, JULY, 2), 0},
 144             {date(2012, JULY, 2), date(2012, JULY, 3), 0},
 145 
 146             {date(2012, JULY, 2), date(2012, AUGUST, 1), 0},
 147             {date(2012, JULY, 2), date(2012, AUGUST, 2), 1},
 148             {date(2012, JULY, 2), date(2012, AUGUST, 3), 1},
 149 
 150             {date(2012, JULY, 2), date(2012, SEPTEMBER, 1), 1},
 151             {date(2012, JULY, 2), date(2012, SEPTEMBER, 2), 2},
 152             {date(2012, JULY, 2), date(2012, SEPTEMBER, 3), 2},
 153 
 154             {date(2012, JULY, 2), date(2012, JUNE, 1), -1},
 155             {date(2012, JULY, 2), date(2012, JUNE, 2), -1},
 156             {date(2012, JULY, 2), date(2012, JUNE, 3), 0},
 157 
 158             {date(2012, FEBRUARY, 27), date(2012, MARCH, 26), 0},
 159             {date(2012, FEBRUARY, 27), date(2012, MARCH, 27), 1},
 160             {date(2012, FEBRUARY, 27), date(2012, MARCH, 28), 1},
 161 
 162             {date(2012, FEBRUARY, 28), date(2012, MARCH, 27), 0},
 163             {date(2012, FEBRUARY, 28), date(2012, MARCH, 28), 1},
 164             {date(2012, FEBRUARY, 28), date(2012, MARCH, 29), 1},
 165 
 166             {date(2012, FEBRUARY, 29), date(2012, MARCH, 28), 0},
 167             {date(2012, FEBRUARY, 29), date(2012, MARCH, 29), 1},
 168             {date(2012, FEBRUARY, 29), date(2012, MARCH, 30), 1},
 169         };
 170     }
 171 
 172     @Test(dataProvider = "monthsBetween")
 173     public void test_monthsBetween(LocalDate start, LocalDate end, long expected) {
 174         assertEquals(MONTHS.between(start, end), expected);

 175     }
 176 
 177     @Test(dataProvider = "monthsBetween")
 178     public void test_monthsBetweenReversed(LocalDate start, LocalDate end, long expected) {
 179         assertEquals(MONTHS.between(end, start), -expected);

 180     }
 181 
 182     @Test(dataProvider = "monthsBetween")
 183     public void test_monthsBetween_LocalDateTimeSameTime(LocalDate start, LocalDate end, long expected) {
 184         assertEquals(MONTHS.between(start.atTime(12, 30), end.atTime(12, 30)), expected);
 185     }
 186 
 187     @Test(dataProvider = "monthsBetween")
 188     public void test_monthsBetween_LocalDateTimeLaterTime(LocalDate start, LocalDate end, long expected) {
 189         assertEquals(MONTHS.between(start.atTime(12, 30), end.atTime(12, 31)), expected);
 190     }
 191 
 192     @Test(dataProvider = "monthsBetween")
 193     public void test_monthsBetween_ZonedDateSameOffset(LocalDate start, LocalDate end, long expected) {
 194         assertEquals(MONTHS.between(start.atStartOfDay(ZoneOffset.ofHours(2)), end.atStartOfDay(ZoneOffset.ofHours(2))), expected);
 195     }
 196 
 197     @Test(dataProvider = "monthsBetween")
 198     public void test_monthsBetween_ZonedDateLaterOffset(LocalDate start, LocalDate end, long expected) {
 199         // +01:00 is later than +02:00
 200         assertEquals(MONTHS.between(start.atStartOfDay(ZoneOffset.ofHours(2)), end.atStartOfDay(ZoneOffset.ofHours(1))), expected);
 201     }
 202 
 203     //-----------------------------------------------------------------------
 204     @DataProvider(name = "weeksBetween")
 205     Object[][] data_weeksBetween() {
 206         return new Object[][] {
 207             {date(2012, JULY, 2), date(2012, JUNE, 25), -1},
 208             {date(2012, JULY, 2), date(2012, JUNE, 26), 0},
 209             {date(2012, JULY, 2), date(2012, JULY, 2), 0},
 210             {date(2012, JULY, 2), date(2012, JULY, 8), 0},
 211             {date(2012, JULY, 2), date(2012, JULY, 9), 1},
 212 
 213             {date(2012, FEBRUARY, 28), date(2012, FEBRUARY, 21), -1},
 214             {date(2012, FEBRUARY, 28), date(2012, FEBRUARY, 22), 0},
 215             {date(2012, FEBRUARY, 28), date(2012, FEBRUARY, 28), 0},
 216             {date(2012, FEBRUARY, 28), date(2012, FEBRUARY, 29), 0},
 217             {date(2012, FEBRUARY, 28), date(2012, MARCH, 1), 0},
 218             {date(2012, FEBRUARY, 28), date(2012, MARCH, 5), 0},
 219             {date(2012, FEBRUARY, 28), date(2012, MARCH, 6), 1},
 220 
 221             {date(2012, FEBRUARY, 29), date(2012, FEBRUARY, 22), -1},
 222             {date(2012, FEBRUARY, 29), date(2012, FEBRUARY, 23), 0},
 223             {date(2012, FEBRUARY, 29), date(2012, FEBRUARY, 28), 0},
 224             {date(2012, FEBRUARY, 29), date(2012, FEBRUARY, 29), 0},
 225             {date(2012, FEBRUARY, 29), date(2012, MARCH, 1), 0},
 226             {date(2012, FEBRUARY, 29), date(2012, MARCH, 6), 0},
 227             {date(2012, FEBRUARY, 29), date(2012, MARCH, 7), 1},
 228         };
 229     }
 230 
 231     @Test(dataProvider = "weeksBetween")
 232     public void test_weeksBetween(LocalDate start, LocalDate end, long expected) {
 233         assertEquals(WEEKS.between(start, end), expected);

 234     }
 235 
 236     @Test(dataProvider = "weeksBetween")
 237     public void test_weeksBetweenReversed(LocalDate start, LocalDate end, long expected) {
 238         assertEquals(WEEKS.between(end, start), -expected);

 239     }
 240 
 241     //-----------------------------------------------------------------------
 242     @DataProvider(name = "daysBetween")
 243     Object[][] data_daysBetween() {
 244         return new Object[][] {
 245             {date(2012, JULY, 2), date(2012, JULY, 1), -1},
 246             {date(2012, JULY, 2), date(2012, JULY, 2), 0},
 247             {date(2012, JULY, 2), date(2012, JULY, 3), 1},
 248 
 249             {date(2012, FEBRUARY, 28), date(2012, FEBRUARY, 27), -1},
 250             {date(2012, FEBRUARY, 28), date(2012, FEBRUARY, 28), 0},
 251             {date(2012, FEBRUARY, 28), date(2012, FEBRUARY, 29), 1},
 252             {date(2012, FEBRUARY, 28), date(2012, MARCH, 1), 2},
 253 
 254             {date(2012, FEBRUARY, 29), date(2012, FEBRUARY, 27), -2},
 255             {date(2012, FEBRUARY, 29), date(2012, FEBRUARY, 28), -1},
 256             {date(2012, FEBRUARY, 29), date(2012, FEBRUARY, 29), 0},
 257             {date(2012, FEBRUARY, 29), date(2012, MARCH, 1), 1},
 258 
 259             {date(2012, MARCH, 1), date(2012, FEBRUARY, 27), -3},
 260             {date(2012, MARCH, 1), date(2012, FEBRUARY, 28), -2},
 261             {date(2012, MARCH, 1), date(2012, FEBRUARY, 29), -1},
 262             {date(2012, MARCH, 1), date(2012, MARCH, 1), 0},
 263             {date(2012, MARCH, 1), date(2012, MARCH, 2), 1},
 264 
 265             {date(2012, MARCH, 1), date(2013, FEBRUARY, 28), 364},
 266             {date(2012, MARCH, 1), date(2013, MARCH, 1), 365},
 267 
 268             {date(2011, MARCH, 1), date(2012, FEBRUARY, 28), 364},
 269             {date(2011, MARCH, 1), date(2012, FEBRUARY, 29), 365},
 270             {date(2011, MARCH, 1), date(2012, MARCH, 1), 366},
 271         };
 272     }
 273 
 274     @Test(dataProvider = "daysBetween")
 275     public void test_daysBetween(LocalDate start, LocalDate end, long expected) {
 276         assertEquals(DAYS.between(start, end), expected);

 277     }
 278 
 279     @Test(dataProvider = "daysBetween")
 280     public void test_daysBetweenReversed(LocalDate start, LocalDate end, long expected) {
 281         assertEquals(DAYS.between(end, start), -expected);

 282     }
 283 
 284     @Test(dataProvider = "daysBetween")
 285     public void test_daysBetween_LocalDateTimeSameTime(LocalDate start, LocalDate end, long expected) {
 286         assertEquals(DAYS.between(start.atTime(12, 30), end.atTime(12, 30)), expected);
 287     }
 288 
 289     @Test(dataProvider = "daysBetween")
 290     public void test_daysBetween_LocalDateTimeLaterTime(LocalDate start, LocalDate end, long expected) {
 291         assertEquals(DAYS.between(start.atTime(12, 30), end.atTime(12, 31)), expected);
 292     }
 293 
 294     @Test(dataProvider = "daysBetween")
 295     public void test_daysBetween_ZonedDateSameOffset(LocalDate start, LocalDate end, long expected) {
 296         assertEquals(DAYS.between(start.atStartOfDay(ZoneOffset.ofHours(2)), end.atStartOfDay(ZoneOffset.ofHours(2))), expected);
 297     }
 298 
 299     @Test(dataProvider = "daysBetween")
 300     public void test_daysBetween_ZonedDateLaterOffset(LocalDate start, LocalDate end, long expected) {
 301         // +01:00 is later than +02:00
 302         assertEquals(DAYS.between(start.atStartOfDay(ZoneOffset.ofHours(2)), end.atStartOfDay(ZoneOffset.ofHours(1))), expected);
 303     }
 304 
 305     //-----------------------------------------------------------------------
 306     private static LocalDate date(int year, Month month, int dom) {
 307         return LocalDate.of(year, month, dom);
 308     }
 309 
 310 }