View Javadoc

1   /*
2    *  Copyright 2001-2013 Stephen Colebourne
3    *
4    *  Licensed under the Apache License, Version 2.0 (the "License");
5    *  you may not use this file except in compliance with the License.
6    *  You may obtain a copy of the License at
7    *
8    *      http://www.apache.org/licenses/LICENSE-2.0
9    *
10   *  Unless required by applicable law or agreed to in writing, software
11   *  distributed under the License is distributed on an "AS IS" BASIS,
12   *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   *  See the License for the specific language governing permissions and
14   *  limitations under the License.
15   */
16  package org.joda.time;
17  
18  import java.util.Calendar;
19  import java.util.Date;
20  import java.util.GregorianCalendar;
21  
22  import junit.framework.TestCase;
23  import junit.framework.TestSuite;
24  
25  import org.joda.time.chrono.BuddhistChronology;
26  import org.joda.time.chrono.GregorianChronology;
27  import org.joda.time.chrono.ISOChronology;
28  import org.joda.time.format.DateTimeFormat;
29  import org.joda.time.format.DateTimeFormatter;
30  
31  /**
32   * This class is a Junit unit test for LocalDate.
33   *
34   * @author Stephen Colebourne
35   */
36  public class TestLocalDate_Constructors extends TestCase {
37  
38      private static final DateTimeZone PARIS = DateTimeZone.forID("Europe/Paris");
39      private static final DateTimeZone LONDON = DateTimeZone.forID("Europe/London");
40      private static final Chronology ISO_UTC = ISOChronology.getInstanceUTC();
41      private static final Chronology BUDDHIST_UTC = BuddhistChronology.getInstanceUTC();
42      private static final Chronology GREGORIAN_UTC = GregorianChronology.getInstanceUTC();
43      private static final Chronology GREGORIAN_PARIS = GregorianChronology.getInstance(PARIS);
44      
45      private long TEST_TIME_NOW =
46              (31L + 28L + 31L + 30L + 31L + 9L -1L) * DateTimeConstants.MILLIS_PER_DAY;
47              
48      private long TEST_TIME1 =
49          (31L + 28L + 31L + 6L -1L) * DateTimeConstants.MILLIS_PER_DAY
50          + 12L * DateTimeConstants.MILLIS_PER_HOUR
51          + 24L * DateTimeConstants.MILLIS_PER_MINUTE;
52      private long TEST_TIME1_ROUNDED =
53          (31L + 28L + 31L + 6L -1L) * DateTimeConstants.MILLIS_PER_DAY;
54      private long TEST_TIME2 =
55          (365L + 31L + 28L + 31L + 30L + 7L -1L) * DateTimeConstants.MILLIS_PER_DAY
56          + 14L * DateTimeConstants.MILLIS_PER_HOUR
57          + 28L * DateTimeConstants.MILLIS_PER_MINUTE;
58  
59      private DateTimeZone zone = null;
60  
61      public static void main(String[] args) {
62          junit.textui.TestRunner.run(suite());
63      }
64  
65      public static TestSuite suite() {
66          return new TestSuite(TestLocalDate_Constructors.class);
67      }
68  
69      public TestLocalDate_Constructors(String name) {
70          super(name);
71      }
72  
73      protected void setUp() throws Exception {
74          DateTimeUtils.setCurrentMillisFixed(TEST_TIME_NOW);
75          zone = DateTimeZone.getDefault();
76          DateTimeZone.setDefault(LONDON);
77      }
78  
79      protected void tearDown() throws Exception {
80          DateTimeUtils.setCurrentMillisSystem();
81          DateTimeZone.setDefault(zone);
82          zone = null;
83      }
84  
85      //-----------------------------------------------------------------------
86      public void testParse_noFormatter() throws Throwable {
87          assertEquals(new LocalDate(2010, 6, 30), LocalDate.parse("2010-06-30"));
88          assertEquals(new LocalDate(2010, 1, 2), LocalDate.parse("2010-002"));
89      }
90  
91      public void testParse_formatter() throws Throwable {
92          DateTimeFormatter f = DateTimeFormat.forPattern("yyyy--dd MM").withChronology(ISOChronology.getInstance(PARIS));
93          assertEquals(new LocalDate(2010, 6, 30), LocalDate.parse("2010--30 06", f));
94      }
95  
96      //-----------------------------------------------------------------------
97      public void testFactory_fromCalendarFields() throws Exception {
98          GregorianCalendar cal = new GregorianCalendar(1970, 1, 3, 4, 5, 6);
99          cal.set(Calendar.MILLISECOND, 7);
100         LocalDate expected = new LocalDate(1970, 2, 3);
101         assertEquals(expected, LocalDate.fromCalendarFields(cal));
102     }
103 
104     public void testFactory_fromCalendarFields_beforeYearZero1() throws Exception {
105         GregorianCalendar cal = new GregorianCalendar(1, 1, 3, 4, 5, 6);
106         cal.set(Calendar.ERA, GregorianCalendar.BC);
107         cal.set(Calendar.MILLISECOND, 7);
108         LocalDate expected = new LocalDate(0, 2, 3);
109         assertEquals(expected, LocalDate.fromCalendarFields(cal));
110     }
111 
112     public void testFactory_fromCalendarFields_beforeYearZero3() throws Exception {
113         GregorianCalendar cal = new GregorianCalendar(3, 1, 3, 4, 5, 6);
114         cal.set(Calendar.ERA, GregorianCalendar.BC);
115         cal.set(Calendar.MILLISECOND, 7);
116         LocalDate expected = new LocalDate(-2, 2, 3);
117         assertEquals(expected, LocalDate.fromCalendarFields(cal));
118     }
119 
120     public void testFactory_fromCalendarFields_null() throws Exception {
121         try {
122             LocalDate.fromCalendarFields((Calendar) null);
123             fail();
124         } catch (IllegalArgumentException ex) {}
125     }
126 
127     //-----------------------------------------------------------------------
128     public void testFactory_fromDateFields_after1970() throws Exception {
129         GregorianCalendar cal = new GregorianCalendar(1970, 1, 3, 4, 5, 6);
130         cal.set(Calendar.MILLISECOND, 7);
131         LocalDate expected = new LocalDate(1970, 2, 3);
132         assertEquals(expected, LocalDate.fromDateFields(cal.getTime()));
133     }
134 
135     public void testFactory_fromDateFields_before1970() throws Exception {
136         GregorianCalendar cal = new GregorianCalendar(1969, 1, 3, 4, 5, 6);
137         cal.set(Calendar.MILLISECOND, 7);
138         LocalDate expected = new LocalDate(1969, 2, 3);
139         assertEquals(expected, LocalDate.fromDateFields(cal.getTime()));
140     }
141 
142     public void testFactory_fromDateFields_beforeYearZero1() throws Exception {
143         GregorianCalendar cal = new GregorianCalendar(1, 1, 3, 4, 5, 6);
144         cal.set(Calendar.ERA, GregorianCalendar.BC);
145         cal.set(Calendar.MILLISECOND, 7);
146         LocalDate expected = new LocalDate(0, 2, 3);
147         assertEquals(expected, LocalDate.fromDateFields(cal.getTime()));
148     }
149 
150     public void testFactory_fromDateFields_beforeYearZero3() throws Exception {
151         GregorianCalendar cal = new GregorianCalendar(3, 1, 3, 4, 5, 6);
152         cal.set(Calendar.ERA, GregorianCalendar.BC);
153         cal.set(Calendar.MILLISECOND, 7);
154         LocalDate expected = new LocalDate(-2, 2, 3);
155         assertEquals(expected, LocalDate.fromDateFields(cal.getTime()));
156     }
157 
158     public void testFactory_fromDateFields_null() throws Exception {
159         try {
160             LocalDate.fromDateFields((Date) null);
161             fail();
162         } catch (IllegalArgumentException ex) {}
163     }
164 
165     //-----------------------------------------------------------------------
166     public void testConstructor() throws Throwable {
167         LocalDate test = new LocalDate();
168         assertEquals(ISO_UTC, test.getChronology());
169         assertEquals(1970, test.getYear());
170         assertEquals(6, test.getMonthOfYear());
171         assertEquals(9, test.getDayOfMonth());
172         assertEquals(test, LocalDate.now());
173     }
174 
175     public void testConstructor_DateTimeZone() throws Throwable {
176         DateTime dt = new DateTime(2005, 6, 8, 23, 59, 0, 0, LONDON);
177         DateTimeUtils.setCurrentMillisFixed(dt.getMillis());
178         // 23:59 in London is 00:59 the following day in Paris
179         
180         LocalDate test = new LocalDate(LONDON);
181         assertEquals(ISO_UTC, test.getChronology());
182         assertEquals(2005, test.getYear());
183         assertEquals(6, test.getMonthOfYear());
184         assertEquals(8, test.getDayOfMonth());
185         assertEquals(test, LocalDate.now(LONDON));
186         
187         test = new LocalDate(PARIS);
188         assertEquals(ISO_UTC, test.getChronology());
189         assertEquals(2005, test.getYear());
190         assertEquals(6, test.getMonthOfYear());
191         assertEquals(9, test.getDayOfMonth());
192         assertEquals(test, LocalDate.now(PARIS));
193     }
194 
195     public void testConstructor_nullDateTimeZone() throws Throwable {
196         DateTime dt = new DateTime(2005, 6, 8, 23, 59, 0, 0, LONDON);
197         DateTimeUtils.setCurrentMillisFixed(dt.getMillis());
198         // 23:59 in London is 00:59 the following day in Paris
199         
200         LocalDate test = new LocalDate((DateTimeZone) null);
201         assertEquals(ISO_UTC, test.getChronology());
202         assertEquals(2005, test.getYear());
203         assertEquals(6, test.getMonthOfYear());
204         assertEquals(8, test.getDayOfMonth());
205     }
206 
207     public void testConstructor_Chronology() throws Throwable {
208         LocalDate test = new LocalDate(GREGORIAN_PARIS);
209         assertEquals(GREGORIAN_UTC, test.getChronology());
210         assertEquals(1970, test.getYear());
211         assertEquals(6, test.getMonthOfYear());
212         assertEquals(9, test.getDayOfMonth());
213         assertEquals(test, LocalDate.now(GREGORIAN_PARIS));
214     }
215 
216     public void testConstructor_nullChronology() throws Throwable {
217         LocalDate test = new LocalDate((Chronology) null);
218         assertEquals(ISO_UTC, test.getChronology());
219         assertEquals(1970, test.getYear());
220         assertEquals(6, test.getMonthOfYear());
221         assertEquals(9, test.getDayOfMonth());
222     }
223 
224     //-----------------------------------------------------------------------
225     public void testConstructor_long1() throws Throwable {
226         LocalDate test = new LocalDate(TEST_TIME1);
227         assertEquals(ISO_UTC, test.getChronology());
228         assertEquals(1970, test.getYear());
229         assertEquals(4, test.getMonthOfYear());
230         assertEquals(6, test.getDayOfMonth());
231     }
232 
233     public void testConstructor_long2() throws Throwable {
234         LocalDate test = new LocalDate(TEST_TIME2);
235         assertEquals(ISO_UTC, test.getChronology());
236         assertEquals(1971, test.getYear());
237         assertEquals(5, test.getMonthOfYear());
238         assertEquals(7, test.getDayOfMonth());
239     }
240 
241     public void testConstructor_long1_DateTimeZone() throws Throwable {
242         LocalDate test = new LocalDate(TEST_TIME1, PARIS);
243         assertEquals(ISO_UTC, test.getChronology());
244         assertEquals(1970, test.getYear());
245         assertEquals(4, test.getMonthOfYear());
246         assertEquals(6, test.getDayOfMonth());
247         assertEquals(TEST_TIME1_ROUNDED, test.getLocalMillis());
248     }
249 
250     public void testConstructor_long2_DateTimeZone() throws Throwable {
251         LocalDate test = new LocalDate(TEST_TIME2, PARIS);
252         assertEquals(ISO_UTC, test.getChronology());
253         assertEquals(1971, test.getYear());
254         assertEquals(5, test.getMonthOfYear());
255         assertEquals(7, test.getDayOfMonth());
256     }
257 
258     public void testConstructor_long3_DateTimeZone() throws Throwable {
259         DateTime dt = new DateTime(2006, 6, 9, 0, 0, 0, 0, PARIS);
260         DateTime dtUTC = new DateTime(2006, 6, 9, 0, 0, 0, 0, DateTimeZone.UTC);
261         
262         LocalDate test = new LocalDate(dt.getMillis(), PARIS);
263         assertEquals(ISO_UTC, test.getChronology());
264         assertEquals(2006, test.getYear());
265         assertEquals(6, test.getMonthOfYear());
266         assertEquals(9, test.getDayOfMonth());
267         assertEquals(dtUTC.getMillis(), test.getLocalMillis());
268     }
269 
270     public void testConstructor_long4_DateTimeZone() throws Throwable {
271         DateTime dt = new DateTime(2006, 6, 9, 23, 59, 59, 999, PARIS);
272         DateTime dtUTC = new DateTime(2006, 6, 9, 0, 0, 0, 0, DateTimeZone.UTC);
273         
274         LocalDate test = new LocalDate(dt.getMillis(), PARIS);
275         assertEquals(ISO_UTC, test.getChronology());
276         assertEquals(2006, test.getYear());
277         assertEquals(6, test.getMonthOfYear());
278         assertEquals(9, test.getDayOfMonth());
279         assertEquals(dtUTC.getMillis(), test.getLocalMillis());
280     }
281 
282     public void testConstructor_long_nullDateTimeZone() throws Throwable {
283         LocalDate test = new LocalDate(TEST_TIME1, (DateTimeZone) null);
284         assertEquals(ISO_UTC, test.getChronology());
285         assertEquals(1970, test.getYear());
286         assertEquals(4, test.getMonthOfYear());
287         assertEquals(6, test.getDayOfMonth());
288     }
289 
290     public void testConstructor_long1_Chronology() throws Throwable {
291         LocalDate test = new LocalDate(TEST_TIME1, GREGORIAN_PARIS);
292         assertEquals(GREGORIAN_UTC, test.getChronology());
293         assertEquals(1970, test.getYear());
294         assertEquals(4, test.getMonthOfYear());
295         assertEquals(6, test.getDayOfMonth());
296     }
297 
298     public void testConstructor_long2_Chronology() throws Throwable {
299         LocalDate test = new LocalDate(TEST_TIME2, GREGORIAN_PARIS);
300         assertEquals(GREGORIAN_UTC, test.getChronology());
301         assertEquals(1971, test.getYear());
302         assertEquals(5, test.getMonthOfYear());
303         assertEquals(7, test.getDayOfMonth());
304     }
305 
306     public void testConstructor_long_nullChronology() throws Throwable {
307         LocalDate test = new LocalDate(TEST_TIME1, (Chronology) null);
308         assertEquals(ISO_UTC, test.getChronology());
309         assertEquals(1970, test.getYear());
310         assertEquals(4, test.getMonthOfYear());
311         assertEquals(6, test.getDayOfMonth());
312     }
313 
314     //-----------------------------------------------------------------------
315     public void testConstructor_Object1() throws Throwable {
316         Date date = new Date(TEST_TIME1);
317         LocalDate test = new LocalDate(date);
318         assertEquals(ISO_UTC, test.getChronology());
319         assertEquals(1970, test.getYear());
320         assertEquals(4, test.getMonthOfYear());
321         assertEquals(6, test.getDayOfMonth());
322     }
323 
324     public void testConstructor_nullObject() throws Throwable {
325         LocalDate test = new LocalDate((Object) null);
326         assertEquals(ISO_UTC, test.getChronology());
327         assertEquals(1970, test.getYear());
328         assertEquals(6, test.getMonthOfYear());
329         assertEquals(9, test.getDayOfMonth());
330     }
331 
332     public void testConstructor_ObjectString1() throws Throwable {
333         LocalDate test = new LocalDate("1972-04-06");
334         assertEquals(ISO_UTC, test.getChronology());
335         assertEquals(1972, test.getYear());
336         assertEquals(4, test.getMonthOfYear());
337         assertEquals(6, test.getDayOfMonth());
338     }
339 
340     public void testConstructor_ObjectString2() throws Throwable {
341         LocalDate test = new LocalDate("1972-037");
342         assertEquals(ISO_UTC, test.getChronology());
343         assertEquals(1972, test.getYear());
344         assertEquals(2, test.getMonthOfYear());
345         assertEquals(6, test.getDayOfMonth());
346     }
347 
348     public void testConstructor_ObjectString3() throws Throwable {
349         LocalDate test = new LocalDate("1972-02");
350         assertEquals(ISO_UTC, test.getChronology());
351         assertEquals(1972, test.getYear());
352         assertEquals(2, test.getMonthOfYear());
353         assertEquals(1, test.getDayOfMonth());
354     }
355 
356     public void testConstructor_ObjectStringEx1() throws Throwable {
357         try {
358             new LocalDate("1970-04-06T+14:00");
359             fail();
360         } catch (IllegalArgumentException ex) {}
361     }
362 
363     public void testConstructor_ObjectStringEx2() throws Throwable {
364         try {
365             new LocalDate("1970-04-06T10:20:30.040");
366             fail();
367         } catch (IllegalArgumentException ex) {}
368     }
369 
370     public void testConstructor_ObjectStringEx3() throws Throwable {
371         try {
372             new LocalDate("1970-04-06T10:20:30.040+14:00");
373             fail();
374         } catch (IllegalArgumentException ex) {}
375     }
376 
377     public void testConstructor_ObjectStringEx4() throws Throwable {
378         try {
379             new LocalDate("T10:20:30.040");
380             fail();
381         } catch (IllegalArgumentException ex) {}
382     }
383 
384     public void testConstructor_ObjectStringEx5() throws Throwable {
385         try {
386             new LocalDate("T10:20:30.040+14:00");
387             fail();
388         } catch (IllegalArgumentException ex) {}
389     }
390 
391     public void testConstructor_ObjectStringEx6() throws Throwable {
392         try {
393             new LocalDate("10:20:30.040");
394             fail();
395         } catch (IllegalArgumentException ex) {}
396     }
397 
398     public void testConstructor_ObjectStringEx7() throws Throwable {
399         try {
400             new LocalDate("10:20:30.040+14:00");
401             fail();
402         } catch (IllegalArgumentException ex) {}
403     }
404 
405     public void testConstructor_ObjectLocalDate() throws Throwable {
406         LocalDate date = new LocalDate(1970, 4, 6, BUDDHIST_UTC);
407         LocalDate test = new LocalDate(date);
408         assertEquals(BUDDHIST_UTC, test.getChronology());
409         assertEquals(1970, test.getYear());
410         assertEquals(4, test.getMonthOfYear());
411         assertEquals(6, test.getDayOfMonth());
412     }
413 
414     public void testConstructor_ObjectLocalTime() throws Throwable {
415         LocalTime time = new LocalTime(10, 20, 30, 40, BUDDHIST_UTC);
416         try {
417             new LocalDate(time);
418             fail();
419         } catch (IllegalArgumentException ex) {}
420     }
421 
422     public void testConstructor_ObjectLocalDateTime() throws Throwable {
423         LocalDateTime dt = new LocalDateTime(1970, 5, 6, 10, 20, 30, 40, BUDDHIST_UTC);
424         LocalDate test = new LocalDate(dt);
425         assertEquals(BUDDHIST_UTC, test.getChronology());
426         assertEquals(1970, test.getYear());
427         assertEquals(5, test.getMonthOfYear());
428         assertEquals(6, test.getDayOfMonth());
429     }
430 
431     @SuppressWarnings("deprecation")
432     public void testConstructor_ObjectYearMonthDay() throws Throwable {
433         YearMonthDay date = new YearMonthDay(1970, 4, 6, BUDDHIST_UTC);
434         LocalDate test = new LocalDate(date);
435         assertEquals(BUDDHIST_UTC, test.getChronology());
436         assertEquals(1970, test.getYear());
437         assertEquals(4, test.getMonthOfYear());
438         assertEquals(6, test.getDayOfMonth());
439     }
440 
441     //-----------------------------------------------------------------------
442     public void testConstructor_Object_DateTimeZone() throws Throwable {
443         Date date = new Date(TEST_TIME1);
444         LocalDate test = new LocalDate(date, PARIS);
445         assertEquals(ISO_UTC, test.getChronology());
446         assertEquals(1970, test.getYear());
447         assertEquals(4, test.getMonthOfYear());
448         assertEquals(6, test.getDayOfMonth());
449     }
450 
451     public void testConstructor_nullObject_DateTimeZone() throws Throwable {
452         LocalDate test = new LocalDate((Object) null, PARIS);
453         assertEquals(ISO_UTC, test.getChronology());
454         assertEquals(1970, test.getYear());
455         assertEquals(6, test.getMonthOfYear());
456         assertEquals(9, test.getDayOfMonth());
457     }
458 
459     public void testConstructor_Object_nullDateTimeZone() throws Throwable {
460         Date date = new Date(TEST_TIME1);
461         LocalDate test = new LocalDate(date, (DateTimeZone) null);
462         assertEquals(ISO_UTC, test.getChronology());
463         assertEquals(1970, test.getYear());
464         assertEquals(4, test.getMonthOfYear());
465         assertEquals(6, test.getDayOfMonth());
466     }
467 
468     public void testConstructor_nullObject_nullDateTimeZone() throws Throwable {
469         LocalDate test = new LocalDate((Object) null, (DateTimeZone) null);
470         assertEquals(ISO_UTC, test.getChronology());
471         assertEquals(1970, test.getYear());
472         assertEquals(6, test.getMonthOfYear());
473         assertEquals(9, test.getDayOfMonth());
474     }
475 
476     public void testConstructor_Object_Chronology() throws Throwable {
477         Date date = new Date(TEST_TIME1);
478         LocalDate test = new LocalDate(date, GREGORIAN_PARIS);
479         assertEquals(GREGORIAN_UTC, test.getChronology());
480         assertEquals(1970, test.getYear());
481         assertEquals(4, test.getMonthOfYear());
482         assertEquals(6, test.getDayOfMonth());
483     }
484 
485     public void testConstructor_Object_Chronology_crossChronology() throws Throwable {
486         LocalDate input = new LocalDate(1970, 4, 6, ISO_UTC);
487         LocalDate test = new LocalDate(input, BUDDHIST_UTC);
488         assertEquals(BUDDHIST_UTC, test.getChronology());
489         assertEquals(1970, test.getYear());
490         assertEquals(4, test.getMonthOfYear());
491         assertEquals(6, test.getDayOfMonth());
492     }
493 
494     public void testConstructor_nullObject_Chronology() throws Throwable {
495         LocalDate test = new LocalDate((Object) null, GREGORIAN_PARIS);
496         assertEquals(GREGORIAN_UTC, test.getChronology());
497         assertEquals(1970, test.getYear());
498         assertEquals(6, test.getMonthOfYear());
499         assertEquals(9, test.getDayOfMonth());
500     }
501 
502     public void testConstructor_Object_nullChronology() throws Throwable {
503         Date date = new Date(TEST_TIME1);
504         LocalDate test = new LocalDate(date, (Chronology) null);
505         assertEquals(ISO_UTC, test.getChronology());
506         assertEquals(1970, test.getYear());
507         assertEquals(4, test.getMonthOfYear());
508         assertEquals(6, test.getDayOfMonth());
509     }
510 
511     public void testConstructor_nullObject_nullChronology() throws Throwable {
512         LocalDate test = new LocalDate((Object) null, (Chronology) null);
513         assertEquals(ISO_UTC, test.getChronology());
514         assertEquals(1970, test.getYear());
515         assertEquals(6, test.getMonthOfYear());
516         assertEquals(9, test.getDayOfMonth());
517     }
518 
519     //-----------------------------------------------------------------------
520     public void testConstructor_int_int_int() throws Throwable {
521         LocalDate test = new LocalDate(1970, 6, 9);
522         assertEquals(ISO_UTC, test.getChronology());
523         assertEquals(1970, test.getYear());
524         assertEquals(6, test.getMonthOfYear());
525         assertEquals(9, test.getDayOfMonth());
526         try {
527             new LocalDate(Integer.MIN_VALUE, 6, 9);
528             fail();
529         } catch (IllegalArgumentException ex) {}
530         try {
531             new LocalDate(Integer.MAX_VALUE, 6, 9);
532             fail();
533         } catch (IllegalArgumentException ex) {}
534         try {
535             new LocalDate(1970, 0, 9);
536             fail();
537         } catch (IllegalArgumentException ex) {}
538         try {
539             new LocalDate(1970, 13, 9);
540             fail();
541         } catch (IllegalArgumentException ex) {}
542         try {
543             new LocalDate(1970, 6, 0);
544             fail();
545         } catch (IllegalArgumentException ex) {}
546         try {
547             new LocalDate(1970, 6, 31);
548             fail();
549         } catch (IllegalArgumentException ex) {}
550         new LocalDate(1970, 7, 31);
551         try {
552             new LocalDate(1970, 7, 32);
553             fail();
554         } catch (IllegalArgumentException ex) {}
555     }
556 
557     public void testConstructor_int_int_int_Chronology() throws Throwable {
558         LocalDate test = new LocalDate(1970, 6, 9, GREGORIAN_PARIS);
559         assertEquals(GREGORIAN_UTC, test.getChronology());
560         assertEquals(1970, test.getYear());
561         assertEquals(6, test.getMonthOfYear());
562         assertEquals(9, test.getDayOfMonth());
563         try {
564             new LocalDate(Integer.MIN_VALUE, 6, 9, GREGORIAN_PARIS);
565             fail();
566         } catch (IllegalArgumentException ex) {}
567         try {
568             new LocalDate(Integer.MAX_VALUE, 6, 9, GREGORIAN_PARIS);
569             fail();
570         } catch (IllegalArgumentException ex) {}
571         try {
572             new LocalDate(1970, 0, 9, GREGORIAN_PARIS);
573             fail();
574         } catch (IllegalArgumentException ex) {}
575         try {
576             new LocalDate(1970, 13, 9, GREGORIAN_PARIS);
577             fail();
578         } catch (IllegalArgumentException ex) {}
579         try {
580             new LocalDate(1970, 6, 0, GREGORIAN_PARIS);
581             fail();
582         } catch (IllegalArgumentException ex) {}
583         try {
584             new LocalDate(1970, 6, 31, GREGORIAN_PARIS);
585             fail();
586         } catch (IllegalArgumentException ex) {}
587         new LocalDate(1970, 7, 31, GREGORIAN_PARIS);
588         try {
589             new LocalDate(1970, 7, 32, GREGORIAN_PARIS);
590             fail();
591         } catch (IllegalArgumentException ex) {}
592     }
593 
594     public void testConstructor_int_int_int_nullChronology() throws Throwable {
595         LocalDate test = new LocalDate(1970, 6, 9, null);
596         assertEquals(ISO_UTC, test.getChronology());
597         assertEquals(1970, test.getYear());
598         assertEquals(6, test.getMonthOfYear());
599         assertEquals(9, test.getDayOfMonth());
600     }
601 
602 }