View Javadoc

1   /*
2    *  Copyright 2001-2005 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.chrono;
17  
18  import java.util.Locale;
19  import java.util.TimeZone;
20  
21  import junit.framework.TestCase;
22  import junit.framework.TestSuite;
23  
24  import org.joda.time.DateMidnight;
25  import org.joda.time.DateTime;
26  import org.joda.time.DateTimeConstants;
27  import org.joda.time.DateTimeFieldType;
28  import org.joda.time.DateTimeUtils;
29  import org.joda.time.DateTimeZone;
30  import org.joda.time.DurationField;
31  import org.joda.time.DurationFieldType;
32  import org.joda.time.IllegalFieldValueException;
33  import org.joda.time.Partial;
34  import org.joda.time.TimeOfDay;
35  import org.joda.time.YearMonthDay;
36  
37  /**
38   * This class is a Junit unit test for ISOChronology.
39   *
40   * @author Stephen Colebourne
41   */
42  public class TestISOChronology extends TestCase {
43  
44      private static final DateTimeZone PARIS = DateTimeZone.forID("Europe/Paris");
45      private static final DateTimeZone LONDON = DateTimeZone.forID("Europe/London");
46      private static final DateTimeZone TOKYO = DateTimeZone.forID("Asia/Tokyo");
47  
48      long y2002days = 365 + 365 + 366 + 365 + 365 + 365 + 366 + 365 + 365 + 365 + 
49                       366 + 365 + 365 + 365 + 366 + 365 + 365 + 365 + 366 + 365 + 
50                       365 + 365 + 366 + 365 + 365 + 365 + 366 + 365 + 365 + 365 +
51                       366 + 365;
52      // 2002-06-09
53      private long TEST_TIME_NOW =
54              (y2002days + 31L + 28L + 31L + 30L + 31L + 9L -1L) * DateTimeConstants.MILLIS_PER_DAY;
55  
56      private DateTimeZone originalDateTimeZone = null;
57      private TimeZone originalTimeZone = null;
58      private Locale originalLocale = null;
59  
60      public static void main(String[] args) {
61          junit.textui.TestRunner.run(suite());
62      }
63  
64      public static TestSuite suite() {
65          return new TestSuite(TestISOChronology.class);
66      }
67  
68      public TestISOChronology(String name) {
69          super(name);
70      }
71  
72      protected void setUp() throws Exception {
73          DateTimeUtils.setCurrentMillisFixed(TEST_TIME_NOW);
74          originalDateTimeZone = DateTimeZone.getDefault();
75          originalTimeZone = TimeZone.getDefault();
76          originalLocale = Locale.getDefault();
77          DateTimeZone.setDefault(LONDON);
78          TimeZone.setDefault(TimeZone.getTimeZone("Europe/London"));
79          Locale.setDefault(Locale.UK);
80      }
81  
82      protected void tearDown() throws Exception {
83          DateTimeUtils.setCurrentMillisSystem();
84          DateTimeZone.setDefault(originalDateTimeZone);
85          TimeZone.setDefault(originalTimeZone);
86          Locale.setDefault(originalLocale);
87          originalDateTimeZone = null;
88          originalTimeZone = null;
89          originalLocale = null;
90      }
91  
92      //-----------------------------------------------------------------------
93      public void testFactoryUTC() {
94          assertEquals(DateTimeZone.UTC, ISOChronology.getInstanceUTC().getZone());
95          assertSame(ISOChronology.class, ISOChronology.getInstanceUTC().getClass());
96      }
97  
98      public void testFactory() {
99          assertEquals(LONDON, ISOChronology.getInstance().getZone());
100         assertSame(ISOChronology.class, ISOChronology.getInstance().getClass());
101     }
102 
103     public void testFactory_Zone() {
104         assertEquals(TOKYO, ISOChronology.getInstance(TOKYO).getZone());
105         assertEquals(PARIS, ISOChronology.getInstance(PARIS).getZone());
106         assertEquals(LONDON, ISOChronology.getInstance(null).getZone());
107         assertSame(ISOChronology.class, ISOChronology.getInstance(TOKYO).getClass());
108     }
109 
110     //-----------------------------------------------------------------------
111     public void testEquality() {
112         assertSame(ISOChronology.getInstance(TOKYO), ISOChronology.getInstance(TOKYO));
113         assertSame(ISOChronology.getInstance(LONDON), ISOChronology.getInstance(LONDON));
114         assertSame(ISOChronology.getInstance(PARIS), ISOChronology.getInstance(PARIS));
115         assertSame(ISOChronology.getInstanceUTC(), ISOChronology.getInstanceUTC());
116         assertSame(ISOChronology.getInstance(), ISOChronology.getInstance(LONDON));
117     }
118 
119     public void testWithUTC() {
120         assertSame(ISOChronology.getInstanceUTC(), ISOChronology.getInstance(LONDON).withUTC());
121         assertSame(ISOChronology.getInstanceUTC(), ISOChronology.getInstance(TOKYO).withUTC());
122         assertSame(ISOChronology.getInstanceUTC(), ISOChronology.getInstanceUTC().withUTC());
123         assertSame(ISOChronology.getInstanceUTC(), ISOChronology.getInstance().withUTC());
124     }
125 
126     public void testWithZone() {
127         assertSame(ISOChronology.getInstance(TOKYO), ISOChronology.getInstance(TOKYO).withZone(TOKYO));
128         assertSame(ISOChronology.getInstance(LONDON), ISOChronology.getInstance(TOKYO).withZone(LONDON));
129         assertSame(ISOChronology.getInstance(PARIS), ISOChronology.getInstance(TOKYO).withZone(PARIS));
130         assertSame(ISOChronology.getInstance(LONDON), ISOChronology.getInstance(TOKYO).withZone(null));
131         assertSame(ISOChronology.getInstance(PARIS), ISOChronology.getInstance().withZone(PARIS));
132         assertSame(ISOChronology.getInstance(PARIS), ISOChronology.getInstanceUTC().withZone(PARIS));
133     }
134 
135     public void testToString() {
136         assertEquals("ISOChronology[Europe/London]", ISOChronology.getInstance(LONDON).toString());
137         assertEquals("ISOChronology[Asia/Tokyo]", ISOChronology.getInstance(TOKYO).toString());
138         assertEquals("ISOChronology[Europe/London]", ISOChronology.getInstance().toString());
139         assertEquals("ISOChronology[UTC]", ISOChronology.getInstanceUTC().toString());
140     }
141 
142     //-----------------------------------------------------------------------
143     public void testDurationFields() {
144         assertEquals("eras", ISOChronology.getInstance().eras().getName());
145         assertEquals("centuries", ISOChronology.getInstance().centuries().getName());
146         assertEquals("years", ISOChronology.getInstance().years().getName());
147         assertEquals("weekyears", ISOChronology.getInstance().weekyears().getName());
148         assertEquals("months", ISOChronology.getInstance().months().getName());
149         assertEquals("weeks", ISOChronology.getInstance().weeks().getName());
150         assertEquals("days", ISOChronology.getInstance().days().getName());
151         assertEquals("halfdays", ISOChronology.getInstance().halfdays().getName());
152         assertEquals("hours", ISOChronology.getInstance().hours().getName());
153         assertEquals("minutes", ISOChronology.getInstance().minutes().getName());
154         assertEquals("seconds", ISOChronology.getInstance().seconds().getName());
155         assertEquals("millis", ISOChronology.getInstance().millis().getName());
156         
157         assertEquals(false, ISOChronology.getInstance().eras().isSupported());
158         assertEquals(true, ISOChronology.getInstance().centuries().isSupported());
159         assertEquals(true, ISOChronology.getInstance().years().isSupported());
160         assertEquals(true, ISOChronology.getInstance().weekyears().isSupported());
161         assertEquals(true, ISOChronology.getInstance().months().isSupported());
162         assertEquals(true, ISOChronology.getInstance().weeks().isSupported());
163         assertEquals(true, ISOChronology.getInstance().days().isSupported());
164         assertEquals(true, ISOChronology.getInstance().halfdays().isSupported());
165         assertEquals(true, ISOChronology.getInstance().hours().isSupported());
166         assertEquals(true, ISOChronology.getInstance().minutes().isSupported());
167         assertEquals(true, ISOChronology.getInstance().seconds().isSupported());
168         assertEquals(true, ISOChronology.getInstance().millis().isSupported());
169         
170         assertEquals(false, ISOChronology.getInstance().centuries().isPrecise());
171         assertEquals(false, ISOChronology.getInstance().years().isPrecise());
172         assertEquals(false, ISOChronology.getInstance().weekyears().isPrecise());
173         assertEquals(false, ISOChronology.getInstance().months().isPrecise());
174         assertEquals(false, ISOChronology.getInstance().weeks().isPrecise());
175         assertEquals(false, ISOChronology.getInstance().days().isPrecise());
176         assertEquals(false, ISOChronology.getInstance().halfdays().isPrecise());
177         assertEquals(true, ISOChronology.getInstance().hours().isPrecise());
178         assertEquals(true, ISOChronology.getInstance().minutes().isPrecise());
179         assertEquals(true, ISOChronology.getInstance().seconds().isPrecise());
180         assertEquals(true, ISOChronology.getInstance().millis().isPrecise());
181         
182         assertEquals(false, ISOChronology.getInstanceUTC().centuries().isPrecise());
183         assertEquals(false, ISOChronology.getInstanceUTC().years().isPrecise());
184         assertEquals(false, ISOChronology.getInstanceUTC().weekyears().isPrecise());
185         assertEquals(false, ISOChronology.getInstanceUTC().months().isPrecise());
186         assertEquals(true, ISOChronology.getInstanceUTC().weeks().isPrecise());
187         assertEquals(true, ISOChronology.getInstanceUTC().days().isPrecise());
188         assertEquals(true, ISOChronology.getInstanceUTC().halfdays().isPrecise());
189         assertEquals(true, ISOChronology.getInstanceUTC().hours().isPrecise());
190         assertEquals(true, ISOChronology.getInstanceUTC().minutes().isPrecise());
191         assertEquals(true, ISOChronology.getInstanceUTC().seconds().isPrecise());
192         assertEquals(true, ISOChronology.getInstanceUTC().millis().isPrecise());
193         
194         DateTimeZone gmt = DateTimeZone.forID("Etc/GMT");
195         assertEquals(false, ISOChronology.getInstance(gmt).centuries().isPrecise());
196         assertEquals(false, ISOChronology.getInstance(gmt).years().isPrecise());
197         assertEquals(false, ISOChronology.getInstance(gmt).weekyears().isPrecise());
198         assertEquals(false, ISOChronology.getInstance(gmt).months().isPrecise());
199         assertEquals(true, ISOChronology.getInstance(gmt).weeks().isPrecise());
200         assertEquals(true, ISOChronology.getInstance(gmt).days().isPrecise());
201         assertEquals(true, ISOChronology.getInstance(gmt).halfdays().isPrecise());
202         assertEquals(true, ISOChronology.getInstance(gmt).hours().isPrecise());
203         assertEquals(true, ISOChronology.getInstance(gmt).minutes().isPrecise());
204         assertEquals(true, ISOChronology.getInstance(gmt).seconds().isPrecise());
205         assertEquals(true, ISOChronology.getInstance(gmt).millis().isPrecise());
206         
207         DateTimeZone offset = DateTimeZone.forOffsetHours(1);
208         assertEquals(false, ISOChronology.getInstance(offset).centuries().isPrecise());
209         assertEquals(false, ISOChronology.getInstance(offset).years().isPrecise());
210         assertEquals(false, ISOChronology.getInstance(offset).weekyears().isPrecise());
211         assertEquals(false, ISOChronology.getInstance(offset).months().isPrecise());
212         assertEquals(true, ISOChronology.getInstance(offset).weeks().isPrecise());
213         assertEquals(true, ISOChronology.getInstance(offset).days().isPrecise());
214         assertEquals(true, ISOChronology.getInstance(offset).halfdays().isPrecise());
215         assertEquals(true, ISOChronology.getInstance(offset).hours().isPrecise());
216         assertEquals(true, ISOChronology.getInstance(offset).minutes().isPrecise());
217         assertEquals(true, ISOChronology.getInstance(offset).seconds().isPrecise());
218         assertEquals(true, ISOChronology.getInstance(offset).millis().isPrecise());
219     }
220 
221     public void testDateFields() {
222         assertEquals("era", ISOChronology.getInstance().era().getName());
223         assertEquals("centuryOfEra", ISOChronology.getInstance().centuryOfEra().getName());
224         assertEquals("yearOfCentury", ISOChronology.getInstance().yearOfCentury().getName());
225         assertEquals("yearOfEra", ISOChronology.getInstance().yearOfEra().getName());
226         assertEquals("year", ISOChronology.getInstance().year().getName());
227         assertEquals("monthOfYear", ISOChronology.getInstance().monthOfYear().getName());
228         assertEquals("weekyearOfCentury", ISOChronology.getInstance().weekyearOfCentury().getName());
229         assertEquals("weekyear", ISOChronology.getInstance().weekyear().getName());
230         assertEquals("weekOfWeekyear", ISOChronology.getInstance().weekOfWeekyear().getName());
231         assertEquals("dayOfYear", ISOChronology.getInstance().dayOfYear().getName());
232         assertEquals("dayOfMonth", ISOChronology.getInstance().dayOfMonth().getName());
233         assertEquals("dayOfWeek", ISOChronology.getInstance().dayOfWeek().getName());
234         
235         assertEquals(true, ISOChronology.getInstance().era().isSupported());
236         assertEquals(true, ISOChronology.getInstance().centuryOfEra().isSupported());
237         assertEquals(true, ISOChronology.getInstance().yearOfCentury().isSupported());
238         assertEquals(true, ISOChronology.getInstance().yearOfEra().isSupported());
239         assertEquals(true, ISOChronology.getInstance().year().isSupported());
240         assertEquals(true, ISOChronology.getInstance().monthOfYear().isSupported());
241         assertEquals(true, ISOChronology.getInstance().weekyearOfCentury().isSupported());
242         assertEquals(true, ISOChronology.getInstance().weekyear().isSupported());
243         assertEquals(true, ISOChronology.getInstance().weekOfWeekyear().isSupported());
244         assertEquals(true, ISOChronology.getInstance().dayOfYear().isSupported());
245         assertEquals(true, ISOChronology.getInstance().dayOfMonth().isSupported());
246         assertEquals(true, ISOChronology.getInstance().dayOfWeek().isSupported());
247     }
248 
249     public void testTimeFields() {
250         assertEquals("halfdayOfDay", ISOChronology.getInstance().halfdayOfDay().getName());
251         assertEquals("clockhourOfHalfday", ISOChronology.getInstance().clockhourOfHalfday().getName());
252         assertEquals("hourOfHalfday", ISOChronology.getInstance().hourOfHalfday().getName());
253         assertEquals("clockhourOfDay", ISOChronology.getInstance().clockhourOfDay().getName());
254         assertEquals("hourOfDay", ISOChronology.getInstance().hourOfDay().getName());
255         assertEquals("minuteOfDay", ISOChronology.getInstance().minuteOfDay().getName());
256         assertEquals("minuteOfHour", ISOChronology.getInstance().minuteOfHour().getName());
257         assertEquals("secondOfDay", ISOChronology.getInstance().secondOfDay().getName());
258         assertEquals("secondOfMinute", ISOChronology.getInstance().secondOfMinute().getName());
259         assertEquals("millisOfDay", ISOChronology.getInstance().millisOfDay().getName());
260         assertEquals("millisOfSecond", ISOChronology.getInstance().millisOfSecond().getName());
261         
262         assertEquals(true, ISOChronology.getInstance().halfdayOfDay().isSupported());
263         assertEquals(true, ISOChronology.getInstance().clockhourOfHalfday().isSupported());
264         assertEquals(true, ISOChronology.getInstance().hourOfHalfday().isSupported());
265         assertEquals(true, ISOChronology.getInstance().clockhourOfDay().isSupported());
266         assertEquals(true, ISOChronology.getInstance().hourOfDay().isSupported());
267         assertEquals(true, ISOChronology.getInstance().minuteOfDay().isSupported());
268         assertEquals(true, ISOChronology.getInstance().minuteOfHour().isSupported());
269         assertEquals(true, ISOChronology.getInstance().secondOfDay().isSupported());
270         assertEquals(true, ISOChronology.getInstance().secondOfMinute().isSupported());
271         assertEquals(true, ISOChronology.getInstance().millisOfDay().isSupported());
272         assertEquals(true, ISOChronology.getInstance().millisOfSecond().isSupported());
273     }
274 
275     public void testMaxYear() {
276         final ISOChronology chrono = ISOChronology.getInstanceUTC();
277         final int maxYear = chrono.year().getMaximumValue();
278 
279         DateTime start = new DateTime(maxYear, 1, 1, 0, 0, 0, 0, chrono);
280         DateTime end = new DateTime(maxYear, 12, 31, 23, 59, 59, 999, chrono);
281         assertTrue(start.getMillis() > 0);
282         assertTrue(end.getMillis() > start.getMillis());
283         assertEquals(maxYear, start.getYear());
284         assertEquals(maxYear, end.getYear());
285         long delta = end.getMillis() - start.getMillis();
286         long expectedDelta = 
287             (start.year().isLeap() ? 366L : 365L) * DateTimeConstants.MILLIS_PER_DAY - 1;
288         assertEquals(expectedDelta, delta);
289 
290         assertEquals(start, new DateTime(maxYear + "-01-01T00:00:00.000Z", chrono));
291         assertEquals(end, new DateTime(maxYear + "-12-31T23:59:59.999Z", chrono));
292 
293         try {
294             start.plusYears(1);
295             fail();
296         } catch (IllegalFieldValueException e) {
297         }
298 
299         try {
300             end.plusYears(1);
301             fail();
302         } catch (IllegalFieldValueException e) {
303         }
304 
305         assertEquals(maxYear + 1, chrono.year().get(Long.MAX_VALUE));
306     }
307 
308     public void testMinYear() {
309         final ISOChronology chrono = ISOChronology.getInstanceUTC();
310         final int minYear = chrono.year().getMinimumValue();
311 
312         DateTime start = new DateTime(minYear, 1, 1, 0, 0, 0, 0, chrono);
313         DateTime end = new DateTime(minYear, 12, 31, 23, 59, 59, 999, chrono);
314         assertTrue(start.getMillis() < 0);
315         assertTrue(end.getMillis() > start.getMillis());
316         assertEquals(minYear, start.getYear());
317         assertEquals(minYear, end.getYear());
318         long delta = end.getMillis() - start.getMillis();
319         long expectedDelta = 
320             (start.year().isLeap() ? 366L : 365L) * DateTimeConstants.MILLIS_PER_DAY - 1;
321         assertEquals(expectedDelta, delta);
322 
323         assertEquals(start, new DateTime(minYear + "-01-01T00:00:00.000Z", chrono));
324         assertEquals(end, new DateTime(minYear + "-12-31T23:59:59.999Z", chrono));
325 
326         try {
327             start.minusYears(1);
328             fail();
329         } catch (IllegalFieldValueException e) {
330         }
331 
332         try {
333             end.minusYears(1);
334             fail();
335         } catch (IllegalFieldValueException e) {
336         }
337 
338         assertEquals(minYear - 1, chrono.year().get(Long.MIN_VALUE));
339     }
340 
341     public void testCutoverAddYears() {
342         testAdd("1582-01-01", DurationFieldType.years(), 1, "1583-01-01");
343         testAdd("1582-02-15", DurationFieldType.years(), 1, "1583-02-15");
344         testAdd("1582-02-28", DurationFieldType.years(), 1, "1583-02-28");
345         testAdd("1582-03-01", DurationFieldType.years(), 1, "1583-03-01");
346         testAdd("1582-09-30", DurationFieldType.years(), 1, "1583-09-30");
347         testAdd("1582-10-01", DurationFieldType.years(), 1, "1583-10-01");
348         testAdd("1582-10-04", DurationFieldType.years(), 1, "1583-10-04");
349         testAdd("1582-10-15", DurationFieldType.years(), 1, "1583-10-15");
350         testAdd("1582-10-16", DurationFieldType.years(), 1, "1583-10-16");
351         testAdd("1580-01-01", DurationFieldType.years(), 4, "1584-01-01");
352         testAdd("1580-02-29", DurationFieldType.years(), 4, "1584-02-29");
353         testAdd("1580-10-01", DurationFieldType.years(), 4, "1584-10-01");
354         testAdd("1580-10-10", DurationFieldType.years(), 4, "1584-10-10");
355         testAdd("1580-10-15", DurationFieldType.years(), 4, "1584-10-15");
356         testAdd("1580-12-31", DurationFieldType.years(), 4, "1584-12-31");
357     }
358 
359     public void testAddMonths() {
360         testAdd("1582-01-01", DurationFieldType.months(), 1, "1582-02-01");
361         testAdd("1582-01-01", DurationFieldType.months(), 6, "1582-07-01");
362         testAdd("1582-01-01", DurationFieldType.months(), 12, "1583-01-01");
363         testAdd("1582-11-15", DurationFieldType.months(), 1, "1582-12-15");
364         testAdd("1582-09-04", DurationFieldType.months(), 2, "1582-11-04");
365         testAdd("1582-09-05", DurationFieldType.months(), 2, "1582-11-05");
366         testAdd("1582-09-10", DurationFieldType.months(), 2, "1582-11-10");
367         testAdd("1582-09-15", DurationFieldType.months(), 2, "1582-11-15");
368         testAdd("1580-01-01", DurationFieldType.months(), 48, "1584-01-01");
369         testAdd("1580-02-29", DurationFieldType.months(), 48, "1584-02-29");
370         testAdd("1580-10-01", DurationFieldType.months(), 48, "1584-10-01");
371         testAdd("1580-10-10", DurationFieldType.months(), 48, "1584-10-10");
372         testAdd("1580-10-15", DurationFieldType.months(), 48, "1584-10-15");
373         testAdd("1580-12-31", DurationFieldType.months(), 48, "1584-12-31");
374     }
375 
376     private void testAdd(String start, DurationFieldType type, int amt, String end) {
377         DateTime dtStart = new DateTime(start, ISOChronology.getInstanceUTC());
378         DateTime dtEnd = new DateTime(end, ISOChronology.getInstanceUTC());
379         assertEquals(dtEnd, dtStart.withFieldAdded(type, amt));
380         assertEquals(dtStart, dtEnd.withFieldAdded(type, -amt));
381 
382         DurationField field = type.getField(ISOChronology.getInstanceUTC());
383         int diff = field.getDifference(dtEnd.getMillis(), dtStart.getMillis());
384         assertEquals(amt, diff);
385         
386         if (type == DurationFieldType.years() ||
387             type == DurationFieldType.months() ||
388             type == DurationFieldType.days()) {
389             YearMonthDay ymdStart = new YearMonthDay(start, ISOChronology.getInstanceUTC());
390             YearMonthDay ymdEnd = new YearMonthDay(end, ISOChronology.getInstanceUTC());
391             assertEquals(ymdEnd, ymdStart.withFieldAdded(type, amt));
392             assertEquals(ymdStart, ymdEnd.withFieldAdded(type, -amt));
393         }
394     }
395 
396     public void testTimeOfDayAdd() {
397         TimeOfDay start = new TimeOfDay(12, 30);
398         TimeOfDay end = new TimeOfDay(10, 30);
399         assertEquals(end, start.plusHours(22));
400         assertEquals(start, end.minusHours(22));
401         assertEquals(end, start.plusMinutes(22 * 60));
402         assertEquals(start, end.minusMinutes(22 * 60));
403     }
404 
405     public void testPartialDayOfYearAdd() {
406         Partial start = new Partial().with(DateTimeFieldType.year(), 2000).with(DateTimeFieldType.dayOfYear(), 366);
407         Partial end = new Partial().with(DateTimeFieldType.year(), 2004).with(DateTimeFieldType.dayOfYear(), 366);
408         assertEquals(end, start.withFieldAdded(DurationFieldType.days(), 365 + 365 + 365 + 366));
409         assertEquals(start, end.withFieldAdded(DurationFieldType.days(), -(365 + 365 + 365 + 366)));
410     }
411 
412     public void testMaximumValue() {
413         DateMidnight dt = new DateMidnight(1570, 1, 1);
414         while (dt.getYear() < 1590) {
415             dt = dt.plusDays(1);
416             YearMonthDay ymd = dt.toYearMonthDay();
417             assertEquals(dt.year().getMaximumValue(), ymd.year().getMaximumValue());
418             assertEquals(dt.monthOfYear().getMaximumValue(), ymd.monthOfYear().getMaximumValue());
419             assertEquals(dt.dayOfMonth().getMaximumValue(), ymd.dayOfMonth().getMaximumValue());
420         }
421     }
422 
423 }