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.Locale;
19  
20  import junit.framework.TestCase;
21  import junit.framework.TestSuite;
22  
23  import org.joda.time.chrono.CopticChronology;
24  import org.joda.time.chrono.LenientChronology;
25  import org.joda.time.chrono.StrictChronology;
26  
27  /**
28   * This class is a Junit unit test for DateTime.
29   *
30   * @author Stephen Colebourne
31   * @author Mike Schrag
32   */
33  public class TestDateTime_Properties extends TestCase {
34      // Test in 2002/03 as time zones are more well known
35      // (before the late 90's they were all over the place)
36  
37      private static final DateTimeZone PARIS = DateTimeZone.forID("Europe/Paris");
38      private static final Chronology COPTIC_PARIS = CopticChronology.getInstance(PARIS);
39  
40      //private static final DateTimeZone PARIS = DateTimeZone.forID("Europe/Paris");
41      private static final DateTimeZone LONDON = DateTimeZone.forID("Europe/London");
42      
43      long y2002days = 365 + 365 + 366 + 365 + 365 + 365 + 366 + 365 + 365 + 365 + 
44                       366 + 365 + 365 + 365 + 366 + 365 + 365 + 365 + 366 + 365 + 
45                       365 + 365 + 366 + 365 + 365 + 365 + 366 + 365 + 365 + 365 +
46                       366 + 365;
47      long y2003days = 365 + 365 + 366 + 365 + 365 + 365 + 366 + 365 + 365 + 365 + 
48                       366 + 365 + 365 + 365 + 366 + 365 + 365 + 365 + 366 + 365 + 
49                       365 + 365 + 366 + 365 + 365 + 365 + 366 + 365 + 365 + 365 +
50                       366 + 365 + 365;
51      
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      // 2002-04-05 Fri
57      private long TEST_TIME1 =
58              (y2002days + 31L + 28L + 31L + 5L -1L) * DateTimeConstants.MILLIS_PER_DAY
59              + 12L * DateTimeConstants.MILLIS_PER_HOUR
60              + 24L * DateTimeConstants.MILLIS_PER_MINUTE;
61          
62      // 2003-05-06 Tue
63      private long TEST_TIME2 =
64              (y2003days + 31L + 28L + 31L + 30L + 6L -1L) * DateTimeConstants.MILLIS_PER_DAY
65              + 14L * DateTimeConstants.MILLIS_PER_HOUR
66              + 28L * DateTimeConstants.MILLIS_PER_MINUTE;
67          
68      private DateTimeZone zone = null;
69      private Locale locale = null;
70  
71      public static void main(String[] args) {
72          junit.textui.TestRunner.run(suite());
73      }
74  
75      public static TestSuite suite() {
76          return new TestSuite(TestDateTime_Properties.class);
77      }
78  
79      public TestDateTime_Properties(String name) {
80          super(name);
81      }
82  
83      protected void setUp() throws Exception {
84          DateTimeUtils.setCurrentMillisFixed(TEST_TIME_NOW);
85          zone = DateTimeZone.getDefault();
86          locale = Locale.getDefault();
87          DateTimeZone.setDefault(LONDON);
88          Locale.setDefault(Locale.UK);
89      }
90  
91      protected void tearDown() throws Exception {
92          DateTimeUtils.setCurrentMillisSystem();
93          DateTimeZone.setDefault(zone);
94          Locale.setDefault(locale);
95          zone = null;
96      }
97  
98      //-----------------------------------------------------------------------
99      public void testTest() {
100         assertEquals("2002-06-09T00:00:00.000Z", new Instant(TEST_TIME_NOW).toString());
101         assertEquals("2002-04-05T12:24:00.000Z", new Instant(TEST_TIME1).toString());
102         assertEquals("2003-05-06T14:28:00.000Z", new Instant(TEST_TIME2).toString());
103     }
104 
105     //-----------------------------------------------------------------------
106     public void testPropertyGetEra() {
107         DateTime test = new DateTime(2004, 6, 9, 0, 0, 0, 0);
108         assertSame(test.getChronology().era(), test.era().getField());
109         assertEquals("era", test.era().getName());
110         assertEquals("Property[era]", test.era().toString());
111         assertSame(test, test.era().getDateTime());
112         assertEquals(1, test.era().get());
113         assertEquals("1", test.era().getAsString());
114         assertEquals("AD", test.era().getAsText());
115         assertEquals("AD", test.era().getField().getAsText(1, Locale.ENGLISH));
116         assertEquals("ap. J.-C.", test.era().getAsText(Locale.FRENCH));
117         assertEquals("ap. J.-C.", test.era().getField().getAsText(1, Locale.FRENCH));
118         assertEquals("AD", test.era().getAsShortText());
119         assertEquals("AD", test.era().getField().getAsShortText(1, Locale.ENGLISH));
120         assertEquals("ap. J.-C.", test.era().getAsShortText(Locale.FRENCH));
121         assertEquals("ap. J.-C.", test.era().getField().getAsShortText(1, Locale.FRENCH));
122         assertEquals(test.getChronology().eras(), test.era().getDurationField());
123         assertEquals(null, test.era().getRangeDurationField());
124         assertEquals(2, test.era().getMaximumTextLength(null));
125         assertEquals(9, test.era().getMaximumTextLength(Locale.FRENCH));
126         assertEquals(2, test.era().getMaximumShortTextLength(null));
127         assertEquals(9, test.era().getMaximumShortTextLength(Locale.FRENCH));
128     }
129 
130     //-----------------------------------------------------------------------
131     public void testPropertyGetYearOfEra() {
132         DateTime test = new DateTime(2004, 6, 9, 0, 0, 0, 0);
133         assertSame(test.getChronology().yearOfEra(), test.yearOfEra().getField());
134         assertEquals("yearOfEra", test.yearOfEra().getName());
135         assertEquals("Property[yearOfEra]", test.yearOfEra().toString());
136         assertSame(test, test.yearOfEra().getDateTime());
137         assertEquals(2004, test.yearOfEra().get());
138         assertEquals("2004", test.yearOfEra().getAsString());
139         assertEquals("2004", test.yearOfEra().getAsText());
140         assertEquals("2004", test.yearOfEra().getAsText(Locale.FRENCH));
141         assertEquals("2004", test.yearOfEra().getAsShortText());
142         assertEquals("2004", test.yearOfEra().getAsShortText(Locale.FRENCH));
143         assertEquals(test.getChronology().years(), test.yearOfEra().getDurationField());
144         assertEquals(null, test.yearOfEra().getRangeDurationField());
145         assertEquals(9, test.yearOfEra().getMaximumTextLength(null));
146         assertEquals(9, test.yearOfEra().getMaximumShortTextLength(null));
147     }
148 
149     //-----------------------------------------------------------------------
150     public void testPropertyGetCenturyOfEra() {
151         DateTime test = new DateTime(2004, 6, 9, 0, 0, 0, 0);
152         assertSame(test.getChronology().centuryOfEra(), test.centuryOfEra().getField());
153         assertEquals("centuryOfEra", test.centuryOfEra().getName());
154         assertEquals("Property[centuryOfEra]", test.centuryOfEra().toString());
155         assertSame(test, test.centuryOfEra().getDateTime());
156         assertEquals(20, test.centuryOfEra().get());
157         assertEquals("20", test.centuryOfEra().getAsString());
158         assertEquals("20", test.centuryOfEra().getAsText());
159         assertEquals("20", test.centuryOfEra().getAsText(Locale.FRENCH));
160         assertEquals("20", test.centuryOfEra().getAsShortText());
161         assertEquals("20", test.centuryOfEra().getAsShortText(Locale.FRENCH));
162         assertEquals(test.getChronology().centuries(), test.centuryOfEra().getDurationField());
163         assertEquals(null, test.centuryOfEra().getRangeDurationField());
164         assertEquals(7, test.centuryOfEra().getMaximumTextLength(null));
165         assertEquals(7, test.centuryOfEra().getMaximumShortTextLength(null));
166     }
167 
168     //-----------------------------------------------------------------------
169     public void testPropertyGetYearOfCentury() {
170         DateTime test = new DateTime(2004, 6, 9, 0, 0, 0, 0);
171         assertSame(test.getChronology().yearOfCentury(), test.yearOfCentury().getField());
172         assertEquals("yearOfCentury", test.yearOfCentury().getName());
173         assertEquals("Property[yearOfCentury]", test.yearOfCentury().toString());
174         assertSame(test, test.yearOfCentury().getDateTime());
175         assertEquals(4, test.yearOfCentury().get());
176         assertEquals("4", test.yearOfCentury().getAsString());
177         assertEquals("4", test.yearOfCentury().getAsText());
178         assertEquals("4", test.yearOfCentury().getAsText(Locale.FRENCH));
179         assertEquals("4", test.yearOfCentury().getAsShortText());
180         assertEquals("4", test.yearOfCentury().getAsShortText(Locale.FRENCH));
181         assertEquals(test.getChronology().years(), test.yearOfCentury().getDurationField());
182         assertEquals(test.getChronology().centuries(), test.yearOfCentury().getRangeDurationField());
183         assertEquals(2, test.yearOfCentury().getMaximumTextLength(null));
184         assertEquals(2, test.yearOfCentury().getMaximumShortTextLength(null));
185     }
186 
187     //-----------------------------------------------------------------------
188     public void testPropertyGetWeekyear() {
189         DateTime test = new DateTime(2004, 6, 9, 0, 0, 0, 0);
190         assertSame(test.getChronology().weekyear(), test.weekyear().getField());
191         assertEquals("weekyear", test.weekyear().getName());
192         assertEquals("Property[weekyear]", test.weekyear().toString());
193         assertSame(test, test.weekyear().getDateTime());
194         assertEquals(2004, test.weekyear().get());
195         assertEquals("2004", test.weekyear().getAsString());
196         assertEquals("2004", test.weekyear().getAsText());
197         assertEquals("2004", test.weekyear().getAsText(Locale.FRENCH));
198         assertEquals("2004", test.weekyear().getAsShortText());
199         assertEquals("2004", test.weekyear().getAsShortText(Locale.FRENCH));
200         assertEquals(test.getChronology().weekyears(), test.weekyear().getDurationField());
201         assertEquals(null, test.weekyear().getRangeDurationField());
202         assertEquals(9, test.weekyear().getMaximumTextLength(null));
203         assertEquals(9, test.weekyear().getMaximumShortTextLength(null));
204     }
205 
206     //-----------------------------------------------------------------------
207     public void testPropertyGetYear() {
208         DateTime test = new DateTime(2004, 6, 9, 0, 0, 0, 0);
209         assertSame(test.getChronology().year(), test.year().getField());
210         assertEquals("year", test.year().getName());
211         assertEquals("Property[year]", test.year().toString());
212         assertSame(test, test.year().getDateTime());
213         assertEquals(2004, test.year().get());
214         assertEquals("2004", test.year().getAsString());
215         assertEquals("2004", test.year().getAsText());
216         assertEquals("2004", test.year().getAsText(Locale.FRENCH));
217         assertEquals("2004", test.year().getAsShortText());
218         assertEquals("2004", test.year().getAsShortText(Locale.FRENCH));
219         assertEquals(test.getChronology().years(), test.year().getDurationField());
220         assertEquals(null, test.year().getRangeDurationField());
221         assertEquals(9, test.year().getMaximumTextLength(null));
222         assertEquals(9, test.year().getMaximumShortTextLength(null));
223         assertEquals(-292275054, test.year().getMinimumValue());
224         assertEquals(-292275054, test.year().getMinimumValueOverall());
225         assertEquals(292278993, test.year().getMaximumValue());
226         assertEquals(292278993, test.year().getMaximumValueOverall());
227     }
228 
229     public void testPropertyLeapYear() {
230         DateTime test = new DateTime(2004, 6, 9, 0, 0, 0, 0);
231         assertEquals(true, test.year().isLeap());
232         assertEquals(1, test.year().getLeapAmount());
233         assertEquals(test.getChronology().days(), test.year().getLeapDurationField());
234         test = new DateTime(2003, 6, 9, 0, 0, 0, 0);
235         assertEquals(false, test.year().isLeap());
236         assertEquals(0, test.year().getLeapAmount());
237         assertEquals(test.getChronology().days(), test.year().getLeapDurationField());
238     }
239 
240     public void testPropertyAddYear() {
241         DateTime test = new DateTime(2004, 6, 9, 0, 0, 0, 0);
242         DateTime copy = test.year().addToCopy(9);
243         assertEquals("2004-06-09T00:00:00.000+01:00", test.toString());
244         assertEquals("2013-06-09T00:00:00.000+01:00", copy.toString());
245         
246         copy = test.year().addToCopy(0);
247         assertEquals("2004-06-09T00:00:00.000+01:00", copy.toString());
248         
249         copy = test.year().addToCopy(292277023 - 2004);
250         assertEquals(292277023, copy.getYear());
251         
252         try {
253             test.year().addToCopy(292278993 - 2004 + 1);
254             fail();
255         } catch (IllegalArgumentException ex) {}
256         
257         copy = test.year().addToCopy(-2004);
258         assertEquals(0, copy.getYear());
259         
260         copy = test.year().addToCopy(-2005);
261         assertEquals(-1, copy.getYear());
262         
263         try {
264             test.year().addToCopy(-292275054 - 2004 - 1);
265             fail();
266         } catch (IllegalArgumentException ex) {}
267     }
268 
269     public void testPropertyAddWrapFieldYear() {
270         DateTime test = new DateTime(2004, 6, 9, 0, 0, 0, 0);
271         DateTime copy = test.year().addWrapFieldToCopy(9);
272         assertEquals("2004-06-09T00:00:00.000+01:00", test.toString());
273         assertEquals("2013-06-09T00:00:00.000+01:00", copy.toString());
274         
275         copy = test.year().addWrapFieldToCopy(0);
276         assertEquals(2004, copy.getYear());
277         
278         copy = test.year().addWrapFieldToCopy(292278993 - 2004 + 1);
279         assertEquals(-292275054, copy.getYear());
280         
281         copy = test.year().addWrapFieldToCopy(-292275054 - 2004 - 1);
282         assertEquals(292278993, copy.getYear());
283     }
284 
285     public void testPropertySetYear() {
286         DateTime test = new DateTime(2004, 6, 9, 0, 0, 0, 0);
287         DateTime copy = test.year().setCopy(1960);
288         assertEquals("2004-06-09T00:00:00.000+01:00", test.toString());
289         assertEquals("1960-06-09T00:00:00.000+01:00", copy.toString());
290     }
291 
292     public void testPropertySetTextYear() {
293         DateTime test = new DateTime(2004, 6, 9, 0, 0, 0, 0);
294         DateTime copy = test.year().setCopy("1960");
295         assertEquals("2004-06-09T00:00:00.000+01:00", test.toString());
296         assertEquals("1960-06-09T00:00:00.000+01:00", copy.toString());
297     }
298 
299     public void testPropertyCompareToYear() {
300         DateTime test1 = new DateTime(TEST_TIME1);
301         DateTime test2 = new DateTime(TEST_TIME2);
302         assertEquals(true, test1.year().compareTo(test2) < 0);
303         assertEquals(true, test2.year().compareTo(test1) > 0);
304         assertEquals(true, test1.year().compareTo(test1) == 0);
305         try {
306             test1.year().compareTo((ReadableInstant) null);
307             fail();
308         } catch (IllegalArgumentException ex) {}
309     }
310 
311     public void testPropertyCompareToYear2() {
312         DateTime test1 = new DateTime(2004, 6, 9, 0, 0, 0, 0);
313         YearMonthDay ymd1 = new YearMonthDay(2003, 6, 9);
314         YearMonthDay ymd2 = new YearMonthDay(2004, 6, 9);
315         YearMonthDay ymd3 = new YearMonthDay(2005, 6, 9);
316         assertEquals(true, test1.year().compareTo(ymd1) > 0);
317         assertEquals(true, test1.year().compareTo(ymd2) == 0);
318         assertEquals(true, test1.year().compareTo(ymd3) < 0);
319         try {
320             test1.year().compareTo((ReadablePartial) null);
321             fail();
322         } catch (IllegalArgumentException ex) {}
323     }
324 
325     public void testPropertyEqualsHashCodeYear() {
326         DateTime test1 = new DateTime(2004, 6, 9, 0, 0, 0, 0);
327         assertEquals(true, test1.year().equals(test1.year()));
328         assertEquals(true, test1.year().equals(new DateTime(2004, 6, 9, 0, 0, 0, 0).year()));
329         assertEquals(false, test1.year().equals(new DateTime(2004, 6, 9, 0, 0, 0, 0).monthOfYear()));
330         assertEquals(false, test1.year().equals(new DateTime(2004, 6, 9, 0, 0, 0, 0, CopticChronology.getInstance()).year()));
331         
332         assertEquals(true, test1.year().hashCode() == test1.year().hashCode());
333         assertEquals(true, test1.year().hashCode() == new DateTime(2004, 6, 9, 0, 0, 0, 0).year().hashCode());
334         assertEquals(false, test1.year().hashCode() == new DateTime(2004, 6, 9, 0, 0, 0, 0).monthOfYear().hashCode());
335         assertEquals(false, test1.year().hashCode() == new DateTime(2004, 6, 9, 0, 0, 0, 0, CopticChronology.getInstance()).year().hashCode());
336     }
337 
338     //-----------------------------------------------------------------------
339     public void testPropertyGetMonthOfYear() {
340         DateTime test = new DateTime(2004, 6, 9, 0, 0, 0, 0);
341         assertSame(test.getChronology().monthOfYear(), test.monthOfYear().getField());
342         assertEquals("monthOfYear", test.monthOfYear().getName());
343         assertEquals("Property[monthOfYear]", test.monthOfYear().toString());
344         assertSame(test, test.monthOfYear().getDateTime());
345         assertEquals(6, test.monthOfYear().get());
346         assertEquals("6", test.monthOfYear().getAsString());
347         assertEquals("June", test.monthOfYear().getAsText());
348         assertEquals("June", test.monthOfYear().getField().getAsText(6, Locale.ENGLISH));
349         assertEquals("juin", test.monthOfYear().getAsText(Locale.FRENCH));
350         assertEquals("juin", test.monthOfYear().getField().getAsText(6, Locale.FRENCH));
351         assertEquals("Jun", test.monthOfYear().getAsShortText());
352         assertEquals("Jun", test.monthOfYear().getField().getAsShortText(6, Locale.ENGLISH));
353         assertEquals("juin", test.monthOfYear().getAsShortText(Locale.FRENCH));
354         assertEquals("juin", test.monthOfYear().getField().getAsShortText(6, Locale.FRENCH));
355         assertEquals(test.getChronology().months(), test.monthOfYear().getDurationField());
356         assertEquals(test.getChronology().years(), test.monthOfYear().getRangeDurationField());
357         assertEquals(9, test.monthOfYear().getMaximumTextLength(null));
358         assertEquals(3, test.monthOfYear().getMaximumShortTextLength(null));
359         test = new DateTime(2004, 7, 9, 0, 0, 0, 0);
360         assertEquals("juillet", test.monthOfYear().getAsText(Locale.FRENCH));
361         assertEquals("juillet", test.monthOfYear().getField().getAsText(7, Locale.FRENCH));
362         assertEquals("juil.", test.monthOfYear().getAsShortText(Locale.FRENCH));
363         assertEquals("juil.", test.monthOfYear().getField().getAsShortText(7, Locale.FRENCH));
364         assertEquals(1, test.monthOfYear().getMinimumValue());
365         assertEquals(1, test.monthOfYear().getMinimumValueOverall());
366         assertEquals(12, test.monthOfYear().getMaximumValue());
367         assertEquals(12, test.monthOfYear().getMaximumValueOverall());
368         assertEquals(1, test.monthOfYear().getMinimumValue());
369         assertEquals(1, test.monthOfYear().getMinimumValueOverall());
370         assertEquals(12, test.monthOfYear().getMaximumValue());
371         assertEquals(12, test.monthOfYear().getMaximumValueOverall());
372     }
373 
374     public void testPropertyLeapMonthOfYear() {
375         DateTime test = new DateTime(2004, 6, 9, 0, 0, 0, 0);
376         assertEquals(false, test.monthOfYear().isLeap());
377         assertEquals(0, test.monthOfYear().getLeapAmount());
378         assertEquals(test.getChronology().days(), test.monthOfYear().getLeapDurationField());
379         
380         test = new DateTime(2004, 2, 9, 0, 0, 0, 0);
381         assertEquals(true, test.monthOfYear().isLeap());
382         assertEquals(1, test.monthOfYear().getLeapAmount());
383         assertEquals(test.getChronology().days(), test.monthOfYear().getLeapDurationField());
384         
385         test = new DateTime(2003, 6, 9, 0, 0, 0, 0);
386         assertEquals(false, test.monthOfYear().isLeap());
387         assertEquals(0, test.monthOfYear().getLeapAmount());
388         assertEquals(test.getChronology().days(), test.monthOfYear().getLeapDurationField());
389         
390         test = new DateTime(2003, 2, 9, 0, 0, 0, 0);
391         assertEquals(false, test.monthOfYear().isLeap());
392         assertEquals(0, test.monthOfYear().getLeapAmount());
393         assertEquals(test.getChronology().days(), test.monthOfYear().getLeapDurationField());
394     }
395 
396     public void testPropertyAddMonthOfYear() {
397         DateTime test = new DateTime(2004, 6, 9, 0, 0, 0, 0);
398         DateTime copy = test.monthOfYear().addToCopy(6);
399         assertEquals("2004-06-09T00:00:00.000+01:00", test.toString());
400         assertEquals("2004-12-09T00:00:00.000Z", copy.toString());
401         
402         copy = test.monthOfYear().addToCopy(7);
403         assertEquals("2005-01-09T00:00:00.000Z", copy.toString());
404         
405         copy = test.monthOfYear().addToCopy(-5);
406         assertEquals("2004-01-09T00:00:00.000Z", copy.toString());
407         
408         copy = test.monthOfYear().addToCopy(-6);
409         assertEquals("2003-12-09T00:00:00.000Z", copy.toString());
410         
411         test = new DateTime(2004, 1, 31, 0, 0, 0, 0);
412         copy = test.monthOfYear().addToCopy(1);
413         assertEquals("2004-01-31T00:00:00.000Z", test.toString());
414         assertEquals("2004-02-29T00:00:00.000Z", copy.toString());
415         
416         copy = test.monthOfYear().addToCopy(2);
417         assertEquals("2004-03-31T00:00:00.000+01:00", copy.toString());
418         
419         copy = test.monthOfYear().addToCopy(3);
420         assertEquals("2004-04-30T00:00:00.000+01:00", copy.toString());
421         
422         test = new DateTime(2003, 1, 31, 0, 0, 0, 0);
423         copy = test.monthOfYear().addToCopy(1);
424         assertEquals("2003-02-28T00:00:00.000Z", copy.toString());
425     }
426 
427     public void testPropertyAddWrapFieldMonthOfYear() {
428         DateTime test = new DateTime(2004, 6, 9, 0, 0, 0, 0);
429         DateTime copy = test.monthOfYear().addWrapFieldToCopy(4);
430         assertEquals("2004-06-09T00:00:00.000+01:00", test.toString());
431         assertEquals("2004-10-09T00:00:00.000+01:00", copy.toString());
432         
433         copy = test.monthOfYear().addWrapFieldToCopy(8);
434         assertEquals("2004-02-09T00:00:00.000Z", copy.toString());
435         
436         copy = test.monthOfYear().addWrapFieldToCopy(-8);
437         assertEquals("2004-10-09T00:00:00.000+01:00", copy.toString());
438         
439         test = new DateTime(2004, 1, 31, 0, 0, 0, 0);
440         copy = test.monthOfYear().addWrapFieldToCopy(1);
441         assertEquals("2004-01-31T00:00:00.000Z", test.toString());
442         assertEquals("2004-02-29T00:00:00.000Z", copy.toString());
443         
444         copy = test.monthOfYear().addWrapFieldToCopy(2);
445         assertEquals("2004-03-31T00:00:00.000+01:00", copy.toString());
446         
447         copy = test.monthOfYear().addWrapFieldToCopy(3);
448         assertEquals("2004-04-30T00:00:00.000+01:00", copy.toString());
449         
450         test = new DateTime(2005, 1, 31, 0, 0, 0, 0);
451         copy = test.monthOfYear().addWrapFieldToCopy(1);
452         assertEquals("2005-01-31T00:00:00.000Z", test.toString());
453         assertEquals("2005-02-28T00:00:00.000Z", copy.toString());
454     }
455 
456     public void testPropertySetMonthOfYear() {
457         DateTime test = new DateTime(2004, 6, 9, 0, 0, 0, 0);
458         DateTime copy = test.monthOfYear().setCopy(12);
459         assertEquals("2004-06-09T00:00:00.000+01:00", test.toString());
460         assertEquals("2004-12-09T00:00:00.000Z", copy.toString());
461         
462         test = new DateTime(2004, 1, 31, 0, 0, 0, 0);
463         copy = test.monthOfYear().setCopy(2);
464         assertEquals("2004-02-29T00:00:00.000Z", copy.toString());
465         
466         try {
467             test.monthOfYear().setCopy(13);
468             fail();
469         } catch (IllegalArgumentException ex) {}
470         try {
471             test.monthOfYear().setCopy(0);
472             fail();
473         } catch (IllegalArgumentException ex) {}
474     }
475 
476     public void testPropertySetTextMonthOfYear() {
477         DateTime test = new DateTime(2004, 6, 9, 0, 0, 0, 0);
478         DateTime copy = test.monthOfYear().setCopy("12");
479         assertEquals("2004-06-09T00:00:00.000+01:00", test.toString());
480         assertEquals("2004-12-09T00:00:00.000Z", copy.toString());
481         
482         copy = test.monthOfYear().setCopy("December");
483         assertEquals("2004-06-09T00:00:00.000+01:00", test.toString());
484         assertEquals("2004-12-09T00:00:00.000Z", copy.toString());
485         
486         copy = test.monthOfYear().setCopy("Dec");
487         assertEquals("2004-06-09T00:00:00.000+01:00", test.toString());
488         assertEquals("2004-12-09T00:00:00.000Z", copy.toString());
489     }
490 
491     public void testPropertyCompareToMonthOfYear() {
492         DateTime test1 = new DateTime(TEST_TIME1);
493         DateTime test2 = new DateTime(TEST_TIME2);
494         assertEquals(true, test1.monthOfYear().compareTo(test2) < 0);
495         assertEquals(true, test2.monthOfYear().compareTo(test1) > 0);
496         assertEquals(true, test1.monthOfYear().compareTo(test1) == 0);
497         try {
498             test1.monthOfYear().compareTo((ReadableInstant) null);
499             fail();
500         } catch (IllegalArgumentException ex) {}
501         
502         DateTime dt1 = new DateTime(TEST_TIME1);
503         DateTime dt2 = new DateTime(TEST_TIME2);
504         assertEquals(true, test1.monthOfYear().compareTo(dt2) < 0);
505         assertEquals(true, test2.monthOfYear().compareTo(dt1) > 0);
506         assertEquals(true, test1.monthOfYear().compareTo(dt1) == 0);
507         try {
508             test1.monthOfYear().compareTo((ReadableInstant) null);
509             fail();
510         } catch (IllegalArgumentException ex) {}
511     }
512 
513     //-----------------------------------------------------------------------
514     public void testPropertyGetDayOfMonth() {
515         DateTime test = new DateTime(2004, 6, 9, 0, 0, 0, 0);
516         assertSame(test.getChronology().dayOfMonth(), test.dayOfMonth().getField());
517         assertEquals("dayOfMonth", test.dayOfMonth().getName());
518         assertEquals("Property[dayOfMonth]", test.dayOfMonth().toString());
519         assertSame(test, test.dayOfMonth().getDateTime());
520         assertEquals(9, test.dayOfMonth().get());
521         assertEquals("9", test.dayOfMonth().getAsString());
522         assertEquals("9", test.dayOfMonth().getAsText());
523         assertEquals("9", test.dayOfMonth().getAsText(Locale.FRENCH));
524         assertEquals("9", test.dayOfMonth().getAsShortText());
525         assertEquals("9", test.dayOfMonth().getAsShortText(Locale.FRENCH));
526         assertEquals(test.getChronology().days(), test.dayOfMonth().getDurationField());
527         assertEquals(test.getChronology().months(), test.dayOfMonth().getRangeDurationField());
528         assertEquals(2, test.dayOfMonth().getMaximumTextLength(null));
529         assertEquals(2, test.dayOfMonth().getMaximumShortTextLength(null));
530         assertEquals(1, test.dayOfMonth().getMinimumValue());
531         assertEquals(1, test.dayOfMonth().getMinimumValueOverall());
532         assertEquals(30, test.dayOfMonth().getMaximumValue());
533         assertEquals(31, test.dayOfMonth().getMaximumValueOverall());
534         assertEquals(false, test.dayOfMonth().isLeap());
535         assertEquals(0, test.dayOfMonth().getLeapAmount());
536         assertEquals(null, test.dayOfMonth().getLeapDurationField());
537     }
538 
539     public void testPropertyGetMaxMinValuesDayOfMonth() {
540         DateTime test = new DateTime(2004, 6, 9, 0, 0, 0, 0);
541         assertEquals(1, test.dayOfMonth().getMinimumValue());
542         assertEquals(1, test.dayOfMonth().getMinimumValueOverall());
543         assertEquals(30, test.dayOfMonth().getMaximumValue());
544         assertEquals(31, test.dayOfMonth().getMaximumValueOverall());
545         test = new DateTime(2004, 7, 9, 0, 0, 0, 0);
546         assertEquals(31, test.dayOfMonth().getMaximumValue());
547         test = new DateTime(2004, 2, 9, 0, 0, 0, 0);
548         assertEquals(29, test.dayOfMonth().getMaximumValue());
549         test = new DateTime(2003, 2, 9, 0, 0, 0, 0);
550         assertEquals(28, test.dayOfMonth().getMaximumValue());
551     }
552 
553     public void testPropertyAddDayOfMonth() {
554         DateTime test = new DateTime(2004, 6, 9, 0, 0, 0, 0);
555         DateTime copy = test.dayOfMonth().addToCopy(9);
556         assertEquals("2004-06-09T00:00:00.000+01:00", test.toString());
557         assertEquals("2004-06-18T00:00:00.000+01:00", copy.toString());
558         
559         copy = test.dayOfMonth().addToCopy(21);
560         assertEquals("2004-06-30T00:00:00.000+01:00", copy.toString());
561         
562         copy = test.dayOfMonth().addToCopy(22);
563         assertEquals("2004-07-01T00:00:00.000+01:00", copy.toString());
564         
565         copy = test.dayOfMonth().addToCopy(22 + 30);
566         assertEquals("2004-07-31T00:00:00.000+01:00", copy.toString());
567         
568         copy = test.dayOfMonth().addToCopy(22 + 31);
569         assertEquals("2004-08-01T00:00:00.000+01:00", copy.toString());
570 
571         copy = test.dayOfMonth().addToCopy(21 + 31 + 31 + 30 + 31 + 30 + 31);
572         assertEquals("2004-12-31T00:00:00.000Z", copy.toString());
573         
574         copy = test.dayOfMonth().addToCopy(22 + 31 + 31 + 30 + 31 + 30 + 31);
575         assertEquals("2005-01-01T00:00:00.000Z", copy.toString());
576         
577         copy = test.dayOfMonth().addToCopy(-8);
578         assertEquals("2004-06-01T00:00:00.000+01:00", copy.toString());
579         
580         copy = test.dayOfMonth().addToCopy(-9);
581         assertEquals("2004-05-31T00:00:00.000+01:00", copy.toString());
582         
583         copy = test.dayOfMonth().addToCopy(-8 - 31 - 30 - 31 - 29 - 31);
584         assertEquals("2004-01-01T00:00:00.000Z", copy.toString());
585         
586         copy = test.dayOfMonth().addToCopy(-9 - 31 - 30 - 31 - 29 - 31);
587         assertEquals("2003-12-31T00:00:00.000Z", copy.toString());
588     }
589 
590     public void testPropertyAddWrapFieldDayOfMonth() {
591         DateTime test = new DateTime(2004, 6, 9, 0, 0, 0, 0);
592         DateTime copy = test.dayOfMonth().addWrapFieldToCopy(21);
593         assertEquals("2004-06-09T00:00:00.000+01:00", test.toString());
594         assertEquals("2004-06-30T00:00:00.000+01:00", copy.toString());
595         
596         copy = test.dayOfMonth().addWrapFieldToCopy(22);
597         assertEquals("2004-06-01T00:00:00.000+01:00", copy.toString());
598         
599         copy = test.dayOfMonth().addWrapFieldToCopy(-12);
600         assertEquals("2004-06-27T00:00:00.000+01:00", copy.toString());
601         
602         test = new DateTime(2004, 7, 9, 0, 0, 0, 0);
603         copy = test.dayOfMonth().addWrapFieldToCopy(21);
604         assertEquals("2004-07-30T00:00:00.000+01:00", copy.toString());
605     
606         copy = test.dayOfMonth().addWrapFieldToCopy(22);
607         assertEquals("2004-07-31T00:00:00.000+01:00", copy.toString());
608     
609         copy = test.dayOfMonth().addWrapFieldToCopy(23);
610         assertEquals("2004-07-01T00:00:00.000+01:00", copy.toString());
611     
612         copy = test.dayOfMonth().addWrapFieldToCopy(-12);
613         assertEquals("2004-07-28T00:00:00.000+01:00", copy.toString());
614     }
615 
616     public void testPropertySetDayOfMonth() {
617         DateTime test = new DateTime(2004, 6, 9, 0, 0, 0, 0);
618         DateTime copy = test.dayOfMonth().setCopy(12);
619         assertEquals("2004-06-09T00:00:00.000+01:00", test.toString());
620         assertEquals("2004-06-12T00:00:00.000+01:00", copy.toString());
621         
622         try {
623             test.dayOfMonth().setCopy(31);
624             fail();
625         } catch (IllegalArgumentException ex) {}
626         try {
627             test.dayOfMonth().setCopy(0);
628             fail();
629         } catch (IllegalArgumentException ex) {}
630     }
631 
632     public void testPropertySetTextDayOfMonth() {
633         DateTime test = new DateTime(2004, 6, 9, 0, 0, 0, 0);
634         DateTime copy = test.dayOfMonth().setCopy("12");
635         assertEquals("2004-06-09T00:00:00.000+01:00", test.toString());
636         assertEquals("2004-06-12T00:00:00.000+01:00", copy.toString());
637     }
638 
639     public void testPropertyWithMaximumValueDayOfMonth() {
640         DateTime test = new DateTime(2004, 6, 9, 0, 0, 0, 0);
641         DateTime copy = test.dayOfMonth().withMaximumValue();
642         assertEquals("2004-06-09T00:00:00.000+01:00", test.toString());
643         assertEquals("2004-06-30T00:00:00.000+01:00", copy.toString());
644     }
645 
646     public void testPropertyWithMaximumValueMillisOfDayDSTGap() {
647         DateTimeZone paris = DateTimeZone.forID("Europe/Paris");
648         DateTime dt = new DateTime(1926, 4, 17, 18, 0, 0, 0, paris);  // DST gap 23:00 to 00:00
649         DateTime test = dt.millisOfDay().withMaximumValue();
650         assertEquals("1926-04-17T22:59:59.999Z", test.toString());
651     }
652 
653     public void testPropertyWithMinimumValueDayOfMonth() {
654         DateTime test = new DateTime(2004, 6, 9, 0, 0, 0, 0);
655         DateTime copy = test.dayOfMonth().withMinimumValue();
656         assertEquals("2004-06-09T00:00:00.000+01:00", test.toString());
657         assertEquals("2004-06-01T00:00:00.000+01:00", copy.toString());
658     }
659 
660     public void testPropertyWithMinimumValueMillisOfDayDSTGap() {
661         DateTimeZone gaza = DateTimeZone.forID("Asia/Gaza");
662         DateTime dt = new DateTime(2001, 4, 20, 18, 0, 0, 0, gaza);  // DST gap 00:00 to 01:00
663         DateTime test = dt.millisOfDay().withMinimumValue();
664         assertEquals("2001-04-20T01:00:00.000+03:00", test.toString());
665     }
666 
667     public void testPropertyCompareToDayOfMonth() {
668         DateTime test1 = new DateTime(TEST_TIME1);
669         DateTime test2 = new DateTime(TEST_TIME2);
670         assertEquals(true, test1.dayOfMonth().compareTo(test2) < 0);
671         assertEquals(true, test2.dayOfMonth().compareTo(test1) > 0);
672         assertEquals(true, test1.dayOfMonth().compareTo(test1) == 0);
673         try {
674             test1.dayOfMonth().compareTo((ReadableInstant) null);
675             fail();
676         } catch (IllegalArgumentException ex) {}
677         
678         DateTime dt1 = new DateTime(TEST_TIME1);
679         DateTime dt2 = new DateTime(TEST_TIME2);
680         assertEquals(true, test1.dayOfMonth().compareTo(dt2) < 0);
681         assertEquals(true, test2.dayOfMonth().compareTo(dt1) > 0);
682         assertEquals(true, test1.dayOfMonth().compareTo(dt1) == 0);
683         try {
684             test1.dayOfMonth().compareTo((ReadableInstant) null);
685             fail();
686         } catch (IllegalArgumentException ex) {}
687     }
688 
689     //-----------------------------------------------------------------------
690     public void testPropertyGetDayOfYear() {
691         // 31+29+31+30+31+9 = 161
692         DateTime test = new DateTime(2004, 6, 9, 0, 0, 0, 0);
693         assertSame(test.getChronology().dayOfYear(), test.dayOfYear().getField());
694         assertEquals("dayOfYear", test.dayOfYear().getName());
695         assertEquals("Property[dayOfYear]", test.dayOfYear().toString());
696         assertSame(test, test.dayOfYear().getDateTime());
697         assertEquals(161, test.dayOfYear().get());
698         assertEquals("161", test.dayOfYear().getAsString());
699         assertEquals("161", test.dayOfYear().getAsText());
700         assertEquals("161", test.dayOfYear().getAsText(Locale.FRENCH));
701         assertEquals("161", test.dayOfYear().getAsShortText());
702         assertEquals("161", test.dayOfYear().getAsShortText(Locale.FRENCH));
703         assertEquals(test.getChronology().days(), test.dayOfYear().getDurationField());
704         assertEquals(test.getChronology().years(), test.dayOfYear().getRangeDurationField());
705         assertEquals(3, test.dayOfYear().getMaximumTextLength(null));
706         assertEquals(3, test.dayOfYear().getMaximumShortTextLength(null));
707         assertEquals(false, test.dayOfYear().isLeap());
708         assertEquals(0, test.dayOfYear().getLeapAmount());
709         assertEquals(null, test.dayOfYear().getLeapDurationField());
710     }
711 
712     public void testPropertyGetMaxMinValuesDayOfYear() {
713         DateTime test = new DateTime(2004, 6, 9, 0, 0, 0, 0);
714         assertEquals(1, test.dayOfYear().getMinimumValue());
715         assertEquals(1, test.dayOfYear().getMinimumValueOverall());
716         assertEquals(366, test.dayOfYear().getMaximumValue());
717         assertEquals(366, test.dayOfYear().getMaximumValueOverall());
718         test = new DateTime(2002, 6, 9, 0, 0, 0, 0);
719         assertEquals(365, test.dayOfYear().getMaximumValue());
720         assertEquals(366, test.dayOfYear().getMaximumValueOverall());
721     }
722 
723     public void testPropertyAddDayOfYear() {
724         DateTime test = new DateTime(2004, 6, 9, 0, 0, 0, 0);
725         DateTime copy = test.dayOfYear().addToCopy(9);
726         assertEquals("2004-06-09T00:00:00.000+01:00", test.toString());
727         assertEquals("2004-06-18T00:00:00.000+01:00", copy.toString());
728         
729         copy = test.dayOfYear().addToCopy(21);
730         assertEquals("2004-06-30T00:00:00.000+01:00", copy.toString());
731         
732         copy = test.dayOfYear().addToCopy(22);
733         assertEquals("2004-07-01T00:00:00.000+01:00", copy.toString());
734         
735         copy = test.dayOfYear().addToCopy(21 + 31 + 31 + 30 + 31 + 30 + 31);
736         assertEquals("2004-12-31T00:00:00.000Z", copy.toString());
737         
738         copy = test.dayOfYear().addToCopy(22 + 31 + 31 + 30 + 31 + 30 + 31);
739         assertEquals("2005-01-01T00:00:00.000Z", copy.toString());
740         
741         copy = test.dayOfYear().addToCopy(-8);
742         assertEquals("2004-06-01T00:00:00.000+01:00", copy.toString());
743         
744         copy = test.dayOfYear().addToCopy(-9);
745         assertEquals("2004-05-31T00:00:00.000+01:00", copy.toString());
746         
747         copy = test.dayOfYear().addToCopy(-8 - 31 - 30 - 31 - 29 - 31);
748         assertEquals("2004-01-01T00:00:00.000Z", copy.toString());
749         
750         copy = test.dayOfYear().addToCopy(-9 - 31 - 30 - 31 - 29 - 31);
751         assertEquals("2003-12-31T00:00:00.000Z", copy.toString());
752     }
753 
754     public void testPropertyAddWrapFieldDayOfYear() {
755         DateTime test = new DateTime(2004, 6, 9, 0, 0, 0, 0);
756         DateTime copy = test.dayOfYear().addWrapFieldToCopy(21);
757         assertEquals("2004-06-09T00:00:00.000+01:00", test.toString());
758         assertEquals("2004-06-30T00:00:00.000+01:00", copy.toString());
759         
760         copy = test.dayOfYear().addWrapFieldToCopy(22);
761         assertEquals("2004-07-01T00:00:00.000+01:00", copy.toString());
762         
763         copy = test.dayOfYear().addWrapFieldToCopy(-12);
764         assertEquals("2004-05-28T00:00:00.000+01:00", copy.toString());
765         
766         copy = test.dayOfYear().addWrapFieldToCopy(205);
767         assertEquals("2004-12-31T00:00:00.000Z", copy.toString());
768         
769         copy = test.dayOfYear().addWrapFieldToCopy(206);
770         assertEquals("2004-01-01T00:00:00.000Z", copy.toString());
771         
772         copy = test.dayOfYear().addWrapFieldToCopy(-160);
773         assertEquals("2004-01-01T00:00:00.000Z", copy.toString());
774         
775         copy = test.dayOfYear().addWrapFieldToCopy(-161);
776         assertEquals("2004-12-31T00:00:00.000Z", copy.toString());
777     }
778 
779     public void testPropertySetDayOfYear() {
780         DateTime test = new DateTime(2004, 6, 9, 0, 0, 0, 0);
781         DateTime copy = test.dayOfYear().setCopy(12);
782         assertEquals("2004-06-09T00:00:00.000+01:00", test.toString());
783         assertEquals("2004-01-12T00:00:00.000Z", copy.toString());
784         
785         try {
786             test.dayOfYear().setCopy(367);
787             fail();
788         } catch (IllegalArgumentException ex) {}
789         try {
790             test.dayOfYear().setCopy(0);
791             fail();
792         } catch (IllegalArgumentException ex) {}
793     }
794 
795     public void testPropertySetTextDayOfYear() {
796         DateTime test = new DateTime(2004, 6, 9, 0, 0, 0, 0);
797         DateTime copy = test.dayOfYear().setCopy("12");
798         assertEquals("2004-06-09T00:00:00.000+01:00", test.toString());
799         assertEquals("2004-01-12T00:00:00.000Z", copy.toString());
800     }
801 
802     public void testPropertyCompareToDayOfYear() {
803         DateTime test1 = new DateTime(TEST_TIME1);
804         DateTime test2 = new DateTime(TEST_TIME2);
805         assertEquals(true, test1.dayOfYear().compareTo(test2) < 0);
806         assertEquals(true, test2.dayOfYear().compareTo(test1) > 0);
807         assertEquals(true, test1.dayOfYear().compareTo(test1) == 0);
808         try {
809             test1.dayOfYear().compareTo((ReadableInstant) null);
810             fail();
811         } catch (IllegalArgumentException ex) {}
812         
813         DateTime dt1 = new DateTime(TEST_TIME1);
814         DateTime dt2 = new DateTime(TEST_TIME2);
815         assertEquals(true, test1.dayOfYear().compareTo(dt2) < 0);
816         assertEquals(true, test2.dayOfYear().compareTo(dt1) > 0);
817         assertEquals(true, test1.dayOfYear().compareTo(dt1) == 0);
818         try {
819             test1.dayOfYear().compareTo((ReadableInstant) null);
820             fail();
821         } catch (IllegalArgumentException ex) {}
822     }
823 
824     //-----------------------------------------------------------------------
825     public void testPropertyGetWeekOfWeekyear() {
826         // 2002-01-01 = Thu
827         // 2002-12-31 = Thu (+364 days)
828         // 2003-12-30 = Thu (+364 days)
829         // 2004-01-03 = Mon             W1
830         // 2004-01-31 = Mon (+28 days)  W5
831         // 2004-02-28 = Mon (+28 days)  W9
832         // 2004-03-27 = Mon (+28 days)  W13
833         // 2004-04-24 = Mon (+28 days)  W17
834         // 2004-05-23 = Mon (+28 days)  W21
835         // 2004-06-05 = Mon (+14 days)  W23
836         // 2004-06-09 = Fri
837         // 2004-12-25 = Mon             W52
838         // 2005-01-01 = Mon             W1
839         DateTime test = new DateTime(2004, 6, 9, 0, 0, 0, 0);
840         assertSame(test.getChronology().weekOfWeekyear(), test.weekOfWeekyear().getField());
841         assertEquals("weekOfWeekyear", test.weekOfWeekyear().getName());
842         assertEquals("Property[weekOfWeekyear]", test.weekOfWeekyear().toString());
843         assertSame(test, test.weekOfWeekyear().getDateTime());
844         assertEquals(24, test.weekOfWeekyear().get());
845         assertEquals("24", test.weekOfWeekyear().getAsString());
846         assertEquals("24", test.weekOfWeekyear().getAsText());
847         assertEquals("24", test.weekOfWeekyear().getAsText(Locale.FRENCH));
848         assertEquals("24", test.weekOfWeekyear().getAsShortText());
849         assertEquals("24", test.weekOfWeekyear().getAsShortText(Locale.FRENCH));
850         assertEquals(test.getChronology().weeks(), test.weekOfWeekyear().getDurationField());
851         assertEquals(test.getChronology().weekyears(), test.weekOfWeekyear().getRangeDurationField());
852         assertEquals(2, test.weekOfWeekyear().getMaximumTextLength(null));
853         assertEquals(2, test.weekOfWeekyear().getMaximumShortTextLength(null));
854         assertEquals(false, test.weekOfWeekyear().isLeap());
855         assertEquals(0, test.weekOfWeekyear().getLeapAmount());
856         assertEquals(null, test.weekOfWeekyear().getLeapDurationField());
857     }
858 
859     public void testPropertyGetMaxMinValuesWeekOfWeekyear() {
860         DateTime test = new DateTime(2004, 6, 9, 0, 0, 0, 0);
861         assertEquals(1, test.weekOfWeekyear().getMinimumValue());
862         assertEquals(1, test.weekOfWeekyear().getMinimumValueOverall());
863         assertEquals(53, test.weekOfWeekyear().getMaximumValue());
864         assertEquals(53, test.weekOfWeekyear().getMaximumValueOverall());
865         test = new DateTime(2005, 6, 9, 0, 0, 0, 0);
866         assertEquals(52, test.weekOfWeekyear().getMaximumValue());
867         assertEquals(53, test.weekOfWeekyear().getMaximumValueOverall());
868     }
869 
870     public void testPropertyAddWeekOfWeekyear() {
871         DateTime test = new DateTime(2004, 6, 7, 0, 0, 0, 0);
872         DateTime copy = test.weekOfWeekyear().addToCopy(1);
873         assertEquals("2004-06-07T00:00:00.000+01:00", test.toString());
874         assertEquals("2004-06-14T00:00:00.000+01:00", copy.toString());
875         
876         copy = test.weekOfWeekyear().addToCopy(29);
877         assertEquals("2004-12-27T00:00:00.000Z", copy.toString());
878         
879         copy = test.weekOfWeekyear().addToCopy(30);
880         assertEquals("2005-01-03T00:00:00.000Z", copy.toString());
881         
882         copy = test.weekOfWeekyear().addToCopy(-22);
883         assertEquals("2004-01-05T00:00:00.000Z", copy.toString());
884         
885         copy = test.weekOfWeekyear().addToCopy(-23);
886         assertEquals("2003-12-29T00:00:00.000Z", copy.toString());
887     }
888 
889     public void testPropertyAddWrapFieldWeekOfWeekyear() {
890         DateTime test = new DateTime(2004, 6, 7, 0, 0, 0, 0);
891         DateTime copy = test.weekOfWeekyear().addWrapFieldToCopy(1);
892         assertEquals("2004-06-07T00:00:00.000+01:00", test.toString());
893         assertEquals("2004-06-14T00:00:00.000+01:00", copy.toString());
894         
895         copy = test.weekOfWeekyear().addWrapFieldToCopy(29);
896         assertEquals("2004-12-27T00:00:00.000Z", copy.toString());
897         
898         copy = test.weekOfWeekyear().addWrapFieldToCopy(30);
899         assertEquals("2003-12-29T00:00:00.000Z", copy.toString());
900         
901         copy = test.weekOfWeekyear().addWrapFieldToCopy(-23);
902         assertEquals("2003-12-29T00:00:00.000Z", copy.toString());
903     }
904 
905     public void testPropertySetWeekOfWeekyear() {
906         DateTime test = new DateTime(2004, 6, 7, 0, 0, 0, 0);
907         DateTime copy = test.weekOfWeekyear().setCopy(4);
908         assertEquals("2004-06-07T00:00:00.000+01:00", test.toString());
909         assertEquals("2004-01-19T00:00:00.000Z", copy.toString());
910         
911         try {
912             test.weekOfWeekyear().setCopy(54);
913             fail();
914         } catch (IllegalArgumentException ex) {}
915         try {
916             test.weekOfWeekyear().setCopy(0);
917             fail();
918         } catch (IllegalArgumentException ex) {}
919     }
920 
921     public void testPropertySetTextWeekOfWeekyear() {
922         DateTime test = new DateTime(2004, 6, 7, 0, 0, 0, 0);
923         DateTime copy = test.weekOfWeekyear().setCopy("4");
924         assertEquals("2004-06-07T00:00:00.000+01:00", test.toString());
925         assertEquals("2004-01-19T00:00:00.000Z", copy.toString());
926     }
927 
928     public void testPropertyCompareToWeekOfWeekyear() {
929         DateTime test1 = new DateTime(TEST_TIME1);
930         DateTime test2 = new DateTime(TEST_TIME2);
931         assertEquals(true, test1.weekOfWeekyear().compareTo(test2) < 0);
932         assertEquals(true, test2.weekOfWeekyear().compareTo(test1) > 0);
933         assertEquals(true, test1.weekOfWeekyear().compareTo(test1) == 0);
934         try {
935             test1.weekOfWeekyear().compareTo((ReadableInstant) null);
936             fail();
937         } catch (IllegalArgumentException ex) {}
938         
939         DateTime dt1 = new DateTime(TEST_TIME1);
940         DateTime dt2 = new DateTime(TEST_TIME2);
941         assertEquals(true, test1.weekOfWeekyear().compareTo(dt2) < 0);
942         assertEquals(true, test2.weekOfWeekyear().compareTo(dt1) > 0);
943         assertEquals(true, test1.weekOfWeekyear().compareTo(dt1) == 0);
944         try {
945             test1.weekOfWeekyear().compareTo((ReadableInstant) null);
946             fail();
947         } catch (IllegalArgumentException ex) {}
948     }
949 
950     //-----------------------------------------------------------------------
951     public void testPropertyGetDayOfWeek() {
952         DateTime test = new DateTime(2004, 6, 9, 0, 0, 0, 0);
953         assertSame(test.getChronology().dayOfWeek(), test.dayOfWeek().getField());
954         assertEquals("dayOfWeek", test.dayOfWeek().getName());
955         assertEquals("Property[dayOfWeek]", test.dayOfWeek().toString());
956         assertSame(test, test.dayOfWeek().getDateTime());
957         assertEquals(3, test.dayOfWeek().get());
958         assertEquals("3", test.dayOfWeek().getAsString());
959         assertEquals("Wednesday", test.dayOfWeek().getAsText());
960         assertEquals("Wednesday", test.dayOfWeek().getField().getAsText(3, Locale.ENGLISH));
961         assertEquals("mercredi", test.dayOfWeek().getAsText(Locale.FRENCH));
962         assertEquals("mercredi", test.dayOfWeek().getField().getAsText(3, Locale.FRENCH));
963         assertEquals("Wed", test.dayOfWeek().getAsShortText());
964         assertEquals("Wed", test.dayOfWeek().getField().getAsShortText(3, Locale.ENGLISH));
965         assertEquals("mer.", test.dayOfWeek().getAsShortText(Locale.FRENCH));
966         assertEquals("mer.", test.dayOfWeek().getField().getAsShortText(3, Locale.FRENCH));
967         assertEquals(test.getChronology().days(), test.dayOfWeek().getDurationField());
968         assertEquals(test.getChronology().weeks(), test.dayOfWeek().getRangeDurationField());
969         assertEquals(9, test.dayOfWeek().getMaximumTextLength(null));
970         assertEquals(8, test.dayOfWeek().getMaximumTextLength(Locale.FRENCH));
971         assertEquals(3, test.dayOfWeek().getMaximumShortTextLength(null));
972         assertEquals(4, test.dayOfWeek().getMaximumShortTextLength(Locale.FRENCH));
973         assertEquals(1, test.dayOfWeek().getMinimumValue());
974         assertEquals(1, test.dayOfWeek().getMinimumValueOverall());
975         assertEquals(7, test.dayOfWeek().getMaximumValue());
976         assertEquals(7, test.dayOfWeek().getMaximumValueOverall());
977         assertEquals(false, test.dayOfWeek().isLeap());
978         assertEquals(0, test.dayOfWeek().getLeapAmount());
979         assertEquals(null, test.dayOfWeek().getLeapDurationField());
980     }
981 
982     public void testPropertyAddDayOfWeek() {
983         DateTime test = new DateTime(2004, 6, 9, 0, 0, 0, 0);
984         DateTime copy = test.dayOfWeek().addToCopy(1);
985         assertEquals("2004-06-09T00:00:00.000+01:00", test.toString());
986         assertEquals("2004-06-10T00:00:00.000+01:00", copy.toString());
987         
988         copy = test.dayOfWeek().addToCopy(21);
989         assertEquals("2004-06-30T00:00:00.000+01:00", copy.toString());
990         
991         copy = test.dayOfWeek().addToCopy(22);
992         assertEquals("2004-07-01T00:00:00.000+01:00", copy.toString());
993         
994         copy = test.dayOfWeek().addToCopy(21 + 31 + 31 + 30 + 31 + 30 + 31);
995         assertEquals("2004-12-31T00:00:00.000Z", copy.toString());
996         
997         copy = test.dayOfWeek().addToCopy(22 + 31 + 31 + 30 + 31 + 30 + 31);
998         assertEquals("2005-01-01T00:00:00.000Z", copy.toString());
999         
1000         copy = test.dayOfWeek().addToCopy(-8);
1001         assertEquals("2004-06-01T00:00:00.000+01:00", copy.toString());
1002         
1003         copy = test.dayOfWeek().addToCopy(-9);
1004         assertEquals("2004-05-31T00:00:00.000+01:00", copy.toString());
1005         
1006         copy = test.dayOfWeek().addToCopy(-8 - 31 - 30 - 31 - 29 - 31);
1007         assertEquals("2004-01-01T00:00:00.000Z", copy.toString());
1008         
1009         copy = test.dayOfWeek().addToCopy(-9 - 31 - 30 - 31 - 29 - 31);
1010         assertEquals("2003-12-31T00:00:00.000Z", copy.toString());
1011     }
1012 
1013     public void testPropertyAddLongDayOfWeek() {
1014         DateTime test = new DateTime(2004, 6, 9, 0, 0, 0, 0);
1015         DateTime copy = test.dayOfWeek().addToCopy(1L);
1016         assertEquals("2004-06-09T00:00:00.000+01:00", test.toString());
1017         assertEquals("2004-06-10T00:00:00.000+01:00", copy.toString());
1018     }        
1019 
1020     public void testPropertyAddWrapFieldDayOfWeek() {
1021         DateTime test = new DateTime(2004, 6, 9, 0, 0, 0, 0);  // Wed
1022         DateTime copy = test.dayOfWeek().addWrapFieldToCopy(1);
1023         assertEquals("2004-06-09T00:00:00.000+01:00", test.toString());
1024         assertEquals("2004-06-10T00:00:00.000+01:00", copy.toString());
1025         
1026         copy = test.dayOfWeek().addWrapFieldToCopy(5);
1027         assertEquals("2004-06-07T00:00:00.000+01:00", copy.toString());
1028         
1029         copy = test.dayOfWeek().addWrapFieldToCopy(-10);
1030         assertEquals("2004-06-13T00:00:00.000+01:00", copy.toString());
1031         
1032         test = new DateTime(2004, 6, 2, 0, 0, 0, 0);
1033         copy = test.dayOfWeek().addWrapFieldToCopy(5);
1034         assertEquals("2004-06-02T00:00:00.000+01:00", test.toString());
1035         assertEquals("2004-05-31T00:00:00.000+01:00", copy.toString());
1036     }
1037 
1038     public void testPropertySetDayOfWeek() {
1039         DateTime test = new DateTime(2004, 6, 9, 0, 0, 0, 0);
1040         DateTime copy = test.dayOfWeek().setCopy(4);
1041         assertEquals("2004-06-09T00:00:00.000+01:00", test.toString());
1042         assertEquals("2004-06-10T00:00:00.000+01:00", copy.toString());
1043         
1044         try {
1045             test.dayOfWeek().setCopy(8);
1046             fail();
1047         } catch (IllegalArgumentException ex) {}
1048         try {
1049             test.dayOfWeek().setCopy(0);
1050             fail();
1051         } catch (IllegalArgumentException ex) {}
1052     }
1053 
1054     public void testPropertySetTextDayOfWeek() {
1055         DateTime test = new DateTime(2004, 6, 9, 0, 0, 0, 0);
1056         DateTime copy = test.dayOfWeek().setCopy("4");
1057         assertEquals("2004-06-09T00:00:00.000+01:00", test.toString());
1058         assertEquals("2004-06-10T00:00:00.000+01:00", copy.toString());
1059         copy = test.dayOfWeek().setCopy("Mon");
1060         assertEquals("2004-06-07T00:00:00.000+01:00", copy.toString());
1061         copy = test.dayOfWeek().setCopy("Tuesday");
1062         assertEquals("2004-06-08T00:00:00.000+01:00", copy.toString());
1063         copy = test.dayOfWeek().setCopy("lundi", Locale.FRENCH);
1064         assertEquals("2004-06-07T00:00:00.000+01:00", copy.toString());
1065     }
1066 
1067     public void testPropertyCompareToDayOfWeek() {
1068         DateTime test1 = new DateTime(TEST_TIME1);
1069         DateTime test2 = new DateTime(TEST_TIME2);
1070         assertEquals(true, test2.dayOfWeek().compareTo(test1) < 0);
1071         assertEquals(true, test1.dayOfWeek().compareTo(test2) > 0);
1072         assertEquals(true, test1.dayOfWeek().compareTo(test1) == 0);
1073         try {
1074             test1.dayOfWeek().compareTo((ReadableInstant) null);
1075             fail();
1076         } catch (IllegalArgumentException ex) {}
1077         
1078         DateTime dt1 = new DateTime(TEST_TIME1);
1079         DateTime dt2 = new DateTime(TEST_TIME2);
1080         assertEquals(true, test2.dayOfWeek().compareTo(dt1) < 0);
1081         assertEquals(true, test1.dayOfWeek().compareTo(dt2) > 0);
1082         assertEquals(true, test1.dayOfWeek().compareTo(dt1) == 0);
1083         try {
1084             test1.dayOfWeek().compareTo((ReadableInstant) null);
1085             fail();
1086         } catch (IllegalArgumentException ex) {}
1087     }
1088 
1089     //-----------------------------------------------------------------------
1090     public void testPropertyGetHourOfDay() {
1091         DateTime test = new DateTime(2004, 6, 9, 13, 23, 43, 53);
1092         assertSame(test.getChronology().hourOfDay(), test.hourOfDay().getField());
1093         assertEquals("hourOfDay", test.hourOfDay().getName());
1094         assertEquals("Property[hourOfDay]", test.hourOfDay().toString());
1095         assertSame(test, test.hourOfDay().getDateTime());
1096         assertEquals(13, test.hourOfDay().get());
1097         assertEquals("13", test.hourOfDay().getAsString());
1098         assertEquals("13", test.hourOfDay().getAsText());
1099         assertEquals("13", test.hourOfDay().getAsText(Locale.FRENCH));
1100         assertEquals("13", test.hourOfDay().getAsShortText());
1101         assertEquals("13", test.hourOfDay().getAsShortText(Locale.FRENCH));
1102         assertEquals(test.getChronology().hours(), test.hourOfDay().getDurationField());
1103         assertEquals(test.getChronology().days(), test.hourOfDay().getRangeDurationField());
1104         assertEquals(2, test.hourOfDay().getMaximumTextLength(null));
1105         assertEquals(2, test.hourOfDay().getMaximumShortTextLength(null));
1106     }
1107 
1108     public void testPropertyGetDifferenceHourOfDay() {
1109         DateTime test1 = new DateTime(2004, 6, 9, 13, 30, 0, 0);
1110         DateTime test2 = new DateTime(2004, 6, 9, 15, 30, 0, 0);
1111         assertEquals(-2, test1.hourOfDay().getDifference(test2));
1112         assertEquals(2, test2.hourOfDay().getDifference(test1));
1113         assertEquals(-2L, test1.hourOfDay().getDifferenceAsLong(test2));
1114         assertEquals(2L, test2.hourOfDay().getDifferenceAsLong(test1));
1115         
1116         DateTime test = new DateTime(TEST_TIME_NOW + (13L * DateTimeConstants.MILLIS_PER_HOUR));
1117         assertEquals(13, test.hourOfDay().getDifference(null));
1118         assertEquals(13L, test.hourOfDay().getDifferenceAsLong(null));
1119     }
1120 
1121     public void testPropertyRoundFloorHourOfDay() {
1122         DateTime test = new DateTime(2004, 6, 9, 13, 30, 0, 0);
1123         DateTime copy = test.hourOfDay().roundFloorCopy();
1124         assertEquals("2004-06-09T13:00:00.000+01:00", copy.toString());
1125     }
1126 
1127     public void testPropertyRoundCeilingHourOfDay() {
1128         DateTime test = new DateTime(2004, 6, 9, 13, 30, 0, 0);
1129         DateTime copy = test.hourOfDay().roundCeilingCopy();
1130         assertEquals("2004-06-09T14:00:00.000+01:00", copy.toString());
1131     }
1132 
1133     public void testPropertyRoundHalfFloorHourOfDay() {
1134         DateTime test = new DateTime(2004, 6, 9, 13, 30, 0, 0);
1135         DateTime copy = test.hourOfDay().roundHalfFloorCopy();
1136         assertEquals("2004-06-09T13:00:00.000+01:00", copy.toString());
1137         
1138         test = new DateTime(2004, 6, 9, 13, 30, 0, 1);
1139         copy = test.hourOfDay().roundHalfFloorCopy();
1140         assertEquals("2004-06-09T14:00:00.000+01:00", copy.toString());
1141         
1142         test = new DateTime(2004, 6, 9, 13, 29, 59, 999);
1143         copy = test.hourOfDay().roundHalfFloorCopy();
1144         assertEquals("2004-06-09T13:00:00.000+01:00", copy.toString());
1145     }
1146 
1147     public void testPropertyRoundHalfCeilingHourOfDay() {
1148         DateTime test = new DateTime(2004, 6, 9, 13, 30, 0, 0);
1149         DateTime copy = test.hourOfDay().roundHalfCeilingCopy();
1150         assertEquals("2004-06-09T14:00:00.000+01:00", copy.toString());
1151         
1152         test = new DateTime(2004, 6, 9, 13, 30, 0, 1);
1153         copy = test.hourOfDay().roundHalfCeilingCopy();
1154         assertEquals("2004-06-09T14:00:00.000+01:00", copy.toString());
1155         
1156         test = new DateTime(2004, 6, 9, 13, 29, 59, 999);
1157         copy = test.hourOfDay().roundHalfCeilingCopy();
1158         assertEquals("2004-06-09T13:00:00.000+01:00", copy.toString());
1159     }
1160 
1161     public void testPropertyRoundHalfEvenHourOfDay() {
1162         DateTime test = new DateTime(2004, 6, 9, 13, 30, 0, 0);
1163         DateTime copy = test.hourOfDay().roundHalfEvenCopy();
1164         assertEquals("2004-06-09T14:00:00.000+01:00", copy.toString());
1165         
1166         test = new DateTime(2004, 6, 9, 14, 30, 0, 0);
1167         copy = test.hourOfDay().roundHalfEvenCopy();
1168         assertEquals("2004-06-09T14:00:00.000+01:00", copy.toString());
1169         
1170         test = new DateTime(2004, 6, 9, 13, 30, 0, 1);
1171         copy = test.hourOfDay().roundHalfEvenCopy();
1172         assertEquals("2004-06-09T14:00:00.000+01:00", copy.toString());
1173         
1174         test = new DateTime(2004, 6, 9, 13, 29, 59, 999);
1175         copy = test.hourOfDay().roundHalfEvenCopy();
1176         assertEquals("2004-06-09T13:00:00.000+01:00", copy.toString());
1177     }
1178 
1179     public void testPropertyRemainderHourOfDay() {
1180         DateTime test = new DateTime(2004, 6, 9, 13, 30, 0, 0);
1181         assertEquals(30L * DateTimeConstants.MILLIS_PER_MINUTE, test.hourOfDay().remainder());
1182     }
1183 
1184     //-----------------------------------------------------------------------
1185     public void testPropertyGetMinuteOfHour() {
1186         DateTime test = new DateTime(2004, 6, 9, 13, 23, 43, 53);
1187         assertSame(test.getChronology().minuteOfHour(), test.minuteOfHour().getField());
1188         assertEquals("minuteOfHour", test.minuteOfHour().getName());
1189         assertEquals("Property[minuteOfHour]", test.minuteOfHour().toString());
1190         assertSame(test, test.minuteOfHour().getDateTime());
1191         assertEquals(23, test.minuteOfHour().get());
1192         assertEquals("23", test.minuteOfHour().getAsString());
1193         assertEquals("23", test.minuteOfHour().getAsText());
1194         assertEquals("23", test.minuteOfHour().getAsText(Locale.FRENCH));
1195         assertEquals("23", test.minuteOfHour().getAsShortText());
1196         assertEquals("23", test.minuteOfHour().getAsShortText(Locale.FRENCH));
1197         assertEquals(test.getChronology().minutes(), test.minuteOfHour().getDurationField());
1198         assertEquals(test.getChronology().hours(), test.minuteOfHour().getRangeDurationField());
1199         assertEquals(2, test.minuteOfHour().getMaximumTextLength(null));
1200         assertEquals(2, test.minuteOfHour().getMaximumShortTextLength(null));
1201     }
1202 
1203     //-----------------------------------------------------------------------
1204     public void testPropertyGetMinuteOfDay() {
1205         DateTime test = new DateTime(2004, 6, 9, 13, 23, 43, 53);
1206         assertSame(test.getChronology().minuteOfDay(), test.minuteOfDay().getField());
1207         assertEquals("minuteOfDay", test.minuteOfDay().getName());
1208         assertEquals("Property[minuteOfDay]", test.minuteOfDay().toString());
1209         assertSame(test, test.minuteOfDay().getDateTime());
1210         assertEquals(803, test.minuteOfDay().get());
1211         assertEquals("803", test.minuteOfDay().getAsString());
1212         assertEquals("803", test.minuteOfDay().getAsText());
1213         assertEquals("803", test.minuteOfDay().getAsText(Locale.FRENCH));
1214         assertEquals("803", test.minuteOfDay().getAsShortText());
1215         assertEquals("803", test.minuteOfDay().getAsShortText(Locale.FRENCH));
1216         assertEquals(test.getChronology().minutes(), test.minuteOfDay().getDurationField());
1217         assertEquals(test.getChronology().days(), test.minuteOfDay().getRangeDurationField());
1218         assertEquals(4, test.minuteOfDay().getMaximumTextLength(null));
1219         assertEquals(4, test.minuteOfDay().getMaximumShortTextLength(null));
1220     }
1221 
1222     //-----------------------------------------------------------------------
1223     public void testPropertyGetSecondOfMinute() {
1224         DateTime test = new DateTime(2004, 6, 9, 13, 23, 43, 53);
1225         assertSame(test.getChronology().secondOfMinute(), test.secondOfMinute().getField());
1226         assertEquals("secondOfMinute", test.secondOfMinute().getName());
1227         assertEquals("Property[secondOfMinute]", test.secondOfMinute().toString());
1228         assertSame(test, test.secondOfMinute().getDateTime());
1229         assertEquals(43, test.secondOfMinute().get());
1230         assertEquals("43", test.secondOfMinute().getAsString());
1231         assertEquals("43", test.secondOfMinute().getAsText());
1232         assertEquals("43", test.secondOfMinute().getAsText(Locale.FRENCH));
1233         assertEquals("43", test.secondOfMinute().getAsShortText());
1234         assertEquals("43", test.secondOfMinute().getAsShortText(Locale.FRENCH));
1235         assertEquals(test.getChronology().seconds(), test.secondOfMinute().getDurationField());
1236         assertEquals(test.getChronology().minutes(), test.secondOfMinute().getRangeDurationField());
1237         assertEquals(2, test.secondOfMinute().getMaximumTextLength(null));
1238         assertEquals(2, test.secondOfMinute().getMaximumShortTextLength(null));
1239     }
1240 
1241     //-----------------------------------------------------------------------
1242     public void testPropertyGetSecondOfDay() {
1243         DateTime test = new DateTime(2004, 6, 9, 13, 23, 43, 53);
1244         assertSame(test.getChronology().secondOfDay(), test.secondOfDay().getField());
1245         assertEquals("secondOfDay", test.secondOfDay().getName());
1246         assertEquals("Property[secondOfDay]", test.secondOfDay().toString());
1247         assertSame(test, test.secondOfDay().getDateTime());
1248         assertEquals(48223, test.secondOfDay().get());
1249         assertEquals("48223", test.secondOfDay().getAsString());
1250         assertEquals("48223", test.secondOfDay().getAsText());
1251         assertEquals("48223", test.secondOfDay().getAsText(Locale.FRENCH));
1252         assertEquals("48223", test.secondOfDay().getAsShortText());
1253         assertEquals("48223", test.secondOfDay().getAsShortText(Locale.FRENCH));
1254         assertEquals(test.getChronology().seconds(), test.secondOfDay().getDurationField());
1255         assertEquals(test.getChronology().days(), test.secondOfDay().getRangeDurationField());
1256         assertEquals(5, test.secondOfDay().getMaximumTextLength(null));
1257         assertEquals(5, test.secondOfDay().getMaximumShortTextLength(null));
1258     }
1259 
1260     //-----------------------------------------------------------------------
1261     public void testPropertyGetMillisOfSecond() {
1262         DateTime test = new DateTime(2004, 6, 9, 13, 23, 43, 53);
1263         assertSame(test.getChronology().millisOfSecond(), test.millisOfSecond().getField());
1264         assertEquals("millisOfSecond", test.millisOfSecond().getName());
1265         assertEquals("Property[millisOfSecond]", test.millisOfSecond().toString());
1266         assertSame(test, test.millisOfSecond().getDateTime());
1267         assertEquals(53, test.millisOfSecond().get());
1268         assertEquals("53", test.millisOfSecond().getAsString());
1269         assertEquals("53", test.millisOfSecond().getAsText());
1270         assertEquals("53", test.millisOfSecond().getAsText(Locale.FRENCH));
1271         assertEquals("53", test.millisOfSecond().getAsShortText());
1272         assertEquals("53", test.millisOfSecond().getAsShortText(Locale.FRENCH));
1273         assertEquals(test.getChronology().millis(), test.millisOfSecond().getDurationField());
1274         assertEquals(test.getChronology().seconds(), test.millisOfSecond().getRangeDurationField());
1275         assertEquals(3, test.millisOfSecond().getMaximumTextLength(null));
1276         assertEquals(3, test.millisOfSecond().getMaximumShortTextLength(null));
1277     }
1278 
1279     //-----------------------------------------------------------------------
1280     public void testPropertyGetMillisOfDay() {
1281         DateTime test = new DateTime(2004, 6, 9, 13, 23, 43, 53);
1282         assertSame(test.getChronology().millisOfDay(), test.millisOfDay().getField());
1283         assertEquals("millisOfDay", test.millisOfDay().getName());
1284         assertEquals("Property[millisOfDay]", test.millisOfDay().toString());
1285         assertSame(test, test.millisOfDay().getDateTime());
1286         assertEquals(48223053, test.millisOfDay().get());
1287         assertEquals("48223053", test.millisOfDay().getAsString());
1288         assertEquals("48223053", test.millisOfDay().getAsText());
1289         assertEquals("48223053", test.millisOfDay().getAsText(Locale.FRENCH));
1290         assertEquals("48223053", test.millisOfDay().getAsShortText());
1291         assertEquals("48223053", test.millisOfDay().getAsShortText(Locale.FRENCH));
1292         assertEquals(test.getChronology().millis(), test.millisOfDay().getDurationField());
1293         assertEquals(test.getChronology().days(), test.millisOfDay().getRangeDurationField());
1294         assertEquals(8, test.millisOfDay().getMaximumTextLength(null));
1295         assertEquals(8, test.millisOfDay().getMaximumShortTextLength(null));
1296     }
1297 
1298     //-----------------------------------------------------------------------
1299     public void testPropertyToIntervalYearOfEra() {
1300       DateTime test = new DateTime(2004, 6, 9, 13, 23, 43, 53);
1301       Interval testInterval = test.yearOfEra().toInterval();
1302       assertEquals(new DateTime(2004, 1, 1, 0, 0, 0, 0), testInterval.getStart());
1303       assertEquals(new DateTime(2005, 1, 1, 0, 0, 0, 0), testInterval.getEnd());
1304     }
1305 
1306     public void testPropertyToIntervalYearOfCentury() {
1307       DateTime test = new DateTime(2004, 6, 9, 13, 23, 43, 53);
1308       Interval testInterval = test.yearOfCentury().toInterval();
1309       assertEquals(new DateTime(2004, 1, 1, 0, 0, 0, 0), testInterval.getStart());
1310       assertEquals(new DateTime(2005, 1, 1, 0, 0, 0, 0), testInterval.getEnd());
1311     }
1312 
1313     public void testPropertyToIntervalYear() {
1314       DateTime test = new DateTime(2004, 6, 9, 13, 23, 43, 53);
1315       Interval testInterval = test.year().toInterval();
1316       assertEquals(new DateTime(2004, 1, 1, 0, 0, 0, 0), testInterval.getStart());
1317       assertEquals(new DateTime(2005, 1, 1, 0, 0, 0, 0), testInterval.getEnd());
1318     }
1319 
1320     public void testPropertyToIntervalMonthOfYear() {
1321       DateTime test = new DateTime(2004, 6, 9, 13, 23, 43, 53);
1322       Interval testInterval = test.monthOfYear().toInterval();
1323       assertEquals(new DateTime(2004, 6, 1, 0, 0, 0, 0), testInterval.getStart());
1324       assertEquals(new DateTime(2004, 7, 1, 0, 0, 0, 0), testInterval.getEnd());
1325     }
1326 
1327     public void testPropertyToIntervalDayOfMonth() {
1328       DateTime test = new DateTime(2004, 6, 9, 13, 23, 43, 53);
1329       Interval testInterval = test.dayOfMonth().toInterval();
1330       assertEquals(new DateTime(2004, 6, 9, 0, 0, 0, 0), testInterval.getStart());
1331       assertEquals(new DateTime(2004, 6, 10, 0, 0, 0, 0), testInterval.getEnd());
1332 
1333       DateTime febTest = new DateTime(2004, 2, 29, 13, 23, 43, 53);
1334       Interval febTestInterval = febTest.dayOfMonth().toInterval();
1335       assertEquals(new DateTime(2004, 2, 29, 0, 0, 0, 0), febTestInterval.getStart());
1336       assertEquals(new DateTime(2004, 3, 1, 0, 0, 0, 0), febTestInterval.getEnd());
1337     }
1338 
1339     public void testPropertyToIntervalHourOfDay() {
1340       DateTime test = new DateTime(2004, 6, 9, 13, 23, 43, 53);
1341       Interval testInterval = test.hourOfDay().toInterval();
1342       assertEquals(new DateTime(2004, 6, 9, 13, 0, 0, 0), testInterval.getStart());
1343       assertEquals(new DateTime(2004, 6, 9, 14, 0, 0, 0), testInterval.getEnd());
1344 
1345       DateTime midnightTest = new DateTime(2004, 6, 9, 23, 23, 43, 53);
1346       Interval midnightTestInterval = midnightTest.hourOfDay().toInterval();
1347       assertEquals(new DateTime(2004, 6, 9, 23, 0, 0, 0), midnightTestInterval.getStart());
1348       assertEquals(new DateTime(2004, 6, 10, 0, 0, 0, 0), midnightTestInterval.getEnd());
1349     }
1350 
1351     public void testPropertyToIntervalMinuteOfHour() {
1352       DateTime test = new DateTime(2004, 6, 9, 13, 23, 43, 53);
1353       Interval testInterval = test.minuteOfHour().toInterval();
1354       assertEquals(new DateTime(2004, 6, 9, 13, 23, 0, 0), testInterval.getStart());
1355       assertEquals(new DateTime(2004, 6, 9, 13, 24, 0, 0), testInterval.getEnd());
1356     }
1357 
1358     public void testPropertyToIntervalSecondOfMinute() {
1359       DateTime test = new DateTime(2004, 6, 9, 13, 23, 43, 53);
1360       Interval testInterval = test.secondOfMinute().toInterval();
1361       assertEquals(new DateTime(2004, 6, 9, 13, 23, 43, 0), testInterval.getStart());
1362       assertEquals(new DateTime(2004, 6, 9, 13, 23, 44, 0), testInterval.getEnd());
1363     }
1364 
1365     public void testPropertyToIntervalMillisOfSecond() {
1366       DateTime test = new DateTime(2004, 6, 9, 13, 23, 43, 53);
1367       Interval testInterval = test.millisOfSecond().toInterval();
1368       assertEquals(new DateTime(2004, 6, 9, 13, 23, 43, 53), testInterval.getStart());
1369       assertEquals(new DateTime(2004, 6, 9, 13, 23, 43, 54), testInterval.getEnd());
1370     }
1371 
1372     public void testPropertyEqualsHashCodeLenient() {
1373         DateTime test1 = new DateTime(1970, 6, 9, 0, 0, 0, 0, LenientChronology.getInstance(COPTIC_PARIS));
1374         DateTime test2 = new DateTime(1970, 6, 9, 0, 0, 0, 0, LenientChronology.getInstance(COPTIC_PARIS));
1375         assertEquals(true, test1.dayOfMonth().equals(test2.dayOfMonth()));
1376         assertEquals(true, test2.dayOfMonth().equals(test1.dayOfMonth()));
1377         assertEquals(true, test1.dayOfMonth().equals(test1.dayOfMonth()));
1378         assertEquals(true, test2.dayOfMonth().equals(test2.dayOfMonth()));
1379         assertEquals(true, test1.dayOfMonth().hashCode() == test2.dayOfMonth().hashCode());
1380         assertEquals(true, test1.dayOfMonth().hashCode() == test1.dayOfMonth().hashCode());
1381         assertEquals(true, test2.dayOfMonth().hashCode() == test2.dayOfMonth().hashCode());
1382     }
1383 
1384     public void testPropertyEqualsHashCodeStrict() {
1385         DateTime test1 = new DateTime(1970, 6, 9, 0, 0, 0, 0, StrictChronology.getInstance(COPTIC_PARIS));
1386         DateTime test2 = new DateTime(1970, 6, 9, 0, 0, 0, 0, StrictChronology.getInstance(COPTIC_PARIS));
1387         assertEquals(true, test1.dayOfMonth().equals(test2.dayOfMonth()));
1388         assertEquals(true, test2.dayOfMonth().equals(test1.dayOfMonth()));
1389         assertEquals(true, test1.dayOfMonth().equals(test1.dayOfMonth()));
1390         assertEquals(true, test2.dayOfMonth().equals(test2.dayOfMonth()));
1391         assertEquals(true, test1.dayOfMonth().hashCode() == test2.dayOfMonth().hashCode());
1392         assertEquals(true, test1.dayOfMonth().hashCode() == test1.dayOfMonth().hashCode());
1393         assertEquals(true, test2.dayOfMonth().hashCode() == test2.dayOfMonth().hashCode());
1394     }
1395 
1396 }