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.format;
17  
18  import java.util.ArrayList;
19  import java.util.Arrays;
20  import java.util.Collection;
21  import java.util.Collections;
22  import java.util.List;
23  
24  import junit.framework.TestCase;
25  import junit.framework.TestSuite;
26  
27  import org.joda.time.DateTimeFieldType;
28  import org.joda.time.Partial;
29  
30  /**
31   * This class is a Junit unit test for ISODateTimeFormat.
32   *
33   * @author Stephen Colebourne
34   */
35  public class TestISODateTimeFormat_Fields extends TestCase {
36  
37      public static void main(String[] args) {
38          junit.textui.TestRunner.run(suite());
39      }
40  
41      public static TestSuite suite() {
42          return new TestSuite(TestISODateTimeFormat_Fields.class);
43      }
44  
45      public TestISODateTimeFormat_Fields(String name) {
46          super(name);
47      }
48  
49      protected void setUp() throws Exception {
50      }
51  
52      protected void tearDown() throws Exception {
53      }
54  
55      //-----------------------------------------------------------------------
56      public void testForFields_null() {
57          try {
58              ISODateTimeFormat.forFields((Collection) null, true, true);
59              fail();
60          } catch (IllegalArgumentException ex) {}
61      }
62  
63      //-----------------------------------------------------------------------
64      public void testForFields_empty() {
65          try {
66              ISODateTimeFormat.forFields(new ArrayList(), true, true);
67              fail();
68          } catch (IllegalArgumentException ex) {}
69      }
70  
71      //-----------------------------------------------------------------------
72      //-----------------------------------------------------------------------
73      //-----------------------------------------------------------------------
74      public void testForFields_calBased_YMD() {
75          DateTimeFieldType[] fields = new DateTimeFieldType[] {
76                  DateTimeFieldType.year(),
77                  DateTimeFieldType.monthOfYear(),
78                  DateTimeFieldType.dayOfMonth(),
79          };
80          int[] values = new int[] {2005, 6, 25};
81          List types = new ArrayList(Arrays.asList(fields));
82          DateTimeFormatter f = ISODateTimeFormat.forFields(types, true, true);
83          assertEquals("2005-06-25", f.print(new Partial(fields, values)));
84          assertEquals(0, types.size());
85          
86          types = new ArrayList(Arrays.asList(fields));
87          f = ISODateTimeFormat.forFields(types, true, false);
88          assertEquals("2005-06-25", f.print(new Partial(fields, values)));
89          assertEquals(0, types.size());
90          
91          types = new ArrayList(Arrays.asList(fields));
92          f = ISODateTimeFormat.forFields(types, false, true);
93          assertEquals("20050625", f.print(new Partial(fields, values)));
94          assertEquals(0, types.size());
95          
96          types = new ArrayList(Arrays.asList(fields));
97          f = ISODateTimeFormat.forFields(types, false, false);
98          assertEquals("20050625", f.print(new Partial(fields, values)));
99          assertEquals(0, types.size());
100     }
101 
102     //-----------------------------------------------------------------------
103     public void testForFields_calBased_YMD_unmodifiable() {
104         DateTimeFieldType[] fields = new DateTimeFieldType[] {
105                 DateTimeFieldType.year(),
106                 DateTimeFieldType.monthOfYear(),
107                 DateTimeFieldType.dayOfMonth(),
108         };
109         int[] values = new int[] {2005, 6, 25};
110         List types = Collections.unmodifiableList(new ArrayList(Arrays.asList(fields)));
111         DateTimeFormatter f = ISODateTimeFormat.forFields(types, true, true);
112         assertEquals("2005-06-25", f.print(new Partial(fields, values)));
113         assertEquals(3, types.size());
114         
115         types = Arrays.asList(fields);
116         f = ISODateTimeFormat.forFields(types, true, true);
117         assertEquals("2005-06-25", f.print(new Partial(fields, values)));
118         assertEquals(3, types.size());
119     }
120 
121     //-----------------------------------------------------------------------
122     public void testForFields_calBased_YMD_duplicates() {
123         DateTimeFieldType[] fields = new DateTimeFieldType[] {
124                 DateTimeFieldType.year(),
125                 DateTimeFieldType.monthOfYear(),
126                 DateTimeFieldType.dayOfMonth(),
127         };
128         DateTimeFieldType[] dupFields = new DateTimeFieldType[] {
129                 DateTimeFieldType.year(),
130                 DateTimeFieldType.monthOfYear(),
131                 DateTimeFieldType.dayOfMonth(),
132                 DateTimeFieldType.monthOfYear(),
133         };
134         int[] values = new int[] {2005, 6, 25};
135         List types = new ArrayList(Arrays.asList(dupFields));
136         DateTimeFormatter f = ISODateTimeFormat.forFields(types, true, true);
137         assertEquals("2005-06-25", f.print(new Partial(fields, values)));
138         assertEquals(0, types.size());
139         
140         types = Arrays.asList(dupFields);
141         f = ISODateTimeFormat.forFields(types, true, true);
142         assertEquals("2005-06-25", f.print(new Partial(fields, values)));
143         assertEquals(4, types.size());
144     }
145 
146     //-----------------------------------------------------------------------
147     public void testForFields_calBased_Y() {
148         DateTimeFieldType[] fields = new DateTimeFieldType[] {
149                 DateTimeFieldType.year(),
150         };
151         int[] values = new int[] {2005};
152         List types = new ArrayList(Arrays.asList(fields));
153         DateTimeFormatter f = ISODateTimeFormat.forFields(types, true, true);
154         assertEquals("2005", f.print(new Partial(fields, values)));
155         assertEquals(0, types.size());
156         
157         types = new ArrayList(Arrays.asList(fields));
158         f = ISODateTimeFormat.forFields(types, true, false);
159         assertEquals("2005", f.print(new Partial(fields, values)));
160         assertEquals(0, types.size());
161         
162         types = new ArrayList(Arrays.asList(fields));
163         f = ISODateTimeFormat.forFields(types, false, true);
164         assertEquals("2005", f.print(new Partial(fields, values)));
165         assertEquals(0, types.size());
166         
167         types = new ArrayList(Arrays.asList(fields));
168         f = ISODateTimeFormat.forFields(types, false, false);
169         assertEquals("2005", f.print(new Partial(fields, values)));
170         assertEquals(0, types.size());
171     }
172 
173     //-----------------------------------------------------------------------
174     public void testForFields_calBased_M() {
175         DateTimeFieldType[] fields = new DateTimeFieldType[] {
176                 DateTimeFieldType.monthOfYear(),
177         };
178         int[] values = new int[] {6};
179         List types = new ArrayList(Arrays.asList(fields));
180         DateTimeFormatter f = ISODateTimeFormat.forFields(types, true, true);
181         assertEquals("--06", f.print(new Partial(fields, values)));
182         assertEquals(0, types.size());
183         
184         types = new ArrayList(Arrays.asList(fields));
185         f = ISODateTimeFormat.forFields(types, true, false);
186         assertEquals("--06", f.print(new Partial(fields, values)));
187         assertEquals(0, types.size());
188         
189         types = new ArrayList(Arrays.asList(fields));
190         f = ISODateTimeFormat.forFields(types, false, true);
191         assertEquals("--06", f.print(new Partial(fields, values)));
192         assertEquals(0, types.size());
193         
194         types = new ArrayList(Arrays.asList(fields));
195         f = ISODateTimeFormat.forFields(types, false, false);
196         assertEquals("--06", f.print(new Partial(fields, values)));
197         assertEquals(0, types.size());
198     }
199 
200     //-----------------------------------------------------------------------
201     public void testForFields_calBased_D() {
202         DateTimeFieldType[] fields = new DateTimeFieldType[] {
203                 DateTimeFieldType.dayOfMonth(),
204         };
205         int[] values = new int[] {25};
206         List types = new ArrayList(Arrays.asList(fields));
207         DateTimeFormatter f = ISODateTimeFormat.forFields(types, true, true);
208         assertEquals("---25", f.print(new Partial(fields, values)));
209         assertEquals(0, types.size());
210         
211         types = new ArrayList(Arrays.asList(fields));
212         f = ISODateTimeFormat.forFields(types, true, false);
213         assertEquals("---25", f.print(new Partial(fields, values)));
214         assertEquals(0, types.size());
215         
216         types = new ArrayList(Arrays.asList(fields));
217         f = ISODateTimeFormat.forFields(types, false, true);
218         assertEquals("---25", f.print(new Partial(fields, values)));
219         assertEquals(0, types.size());
220         
221         types = new ArrayList(Arrays.asList(fields));
222         f = ISODateTimeFormat.forFields(types, false, false);
223         assertEquals("---25", f.print(new Partial(fields, values)));
224         assertEquals(0, types.size());
225     }
226 
227     //-----------------------------------------------------------------------
228     public void testForFields_calBased_YM() {
229         DateTimeFieldType[] fields = new DateTimeFieldType[] {
230                 DateTimeFieldType.year(),
231                 DateTimeFieldType.monthOfYear(),
232         };
233         int[] values = new int[] {2005, 6};
234         List types = new ArrayList(Arrays.asList(fields));
235         DateTimeFormatter f = ISODateTimeFormat.forFields(types, true, true);
236         assertEquals("2005-06", f.print(new Partial(fields, values)));
237         assertEquals(0, types.size());
238         
239         types = new ArrayList(Arrays.asList(fields));
240         f = ISODateTimeFormat.forFields(types, true, false);
241         assertEquals("2005-06", f.print(new Partial(fields, values)));
242         assertEquals(0, types.size());
243         
244         types = new ArrayList(Arrays.asList(fields));
245         f = ISODateTimeFormat.forFields(types, false, true);
246         assertEquals("2005-06", f.print(new Partial(fields, values)));
247         assertEquals(0, types.size());
248         
249         types = new ArrayList(Arrays.asList(fields));
250         f = ISODateTimeFormat.forFields(types, false, false);
251         assertEquals("2005-06", f.print(new Partial(fields, values)));
252         assertEquals(0, types.size());
253     }
254 
255     //-----------------------------------------------------------------------
256     public void testForFields_calBased_MD() {
257         DateTimeFieldType[] fields = new DateTimeFieldType[] {
258                 DateTimeFieldType.monthOfYear(),
259                 DateTimeFieldType.dayOfMonth(),
260         };
261         int[] values = new int[] {6, 25};
262         List types = new ArrayList(Arrays.asList(fields));
263         DateTimeFormatter f = ISODateTimeFormat.forFields(types, true, true);
264         assertEquals("--06-25", f.print(new Partial(fields, values)));
265         assertEquals(0, types.size());
266         
267         types = new ArrayList(Arrays.asList(fields));
268         f = ISODateTimeFormat.forFields(types, true, false);
269         assertEquals("--06-25", f.print(new Partial(fields, values)));
270         assertEquals(0, types.size());
271         
272         types = new ArrayList(Arrays.asList(fields));
273         f = ISODateTimeFormat.forFields(types, false, true);
274         assertEquals("--0625", f.print(new Partial(fields, values)));
275         assertEquals(0, types.size());
276         
277         types = new ArrayList(Arrays.asList(fields));
278         f = ISODateTimeFormat.forFields(types, false, false);
279         assertEquals("--0625", f.print(new Partial(fields, values)));
280         assertEquals(0, types.size());
281     }
282 
283     //-----------------------------------------------------------------------
284     public void testForFields_calBased_YD() {
285         DateTimeFieldType[] fields = new DateTimeFieldType[] {
286                 DateTimeFieldType.year(),
287                 DateTimeFieldType.dayOfMonth(),
288         };
289         int[] values = new int[] {2005, 25};
290         List types = new ArrayList(Arrays.asList(fields));
291         DateTimeFormatter f = ISODateTimeFormat.forFields(types, true, false);
292         assertEquals("2005--25", f.print(new Partial(fields, values)));
293         assertEquals(0, types.size());
294         
295         types = new ArrayList(Arrays.asList(fields));
296         f = ISODateTimeFormat.forFields(types, false, false);
297         assertEquals("2005--25", f.print(new Partial(fields, values)));
298         assertEquals(0, types.size());
299         
300         types = new ArrayList(Arrays.asList(fields));
301         try {
302             ISODateTimeFormat.forFields(types, true, true);
303             fail();
304         } catch (IllegalArgumentException ex) {}
305         
306         types = new ArrayList(Arrays.asList(fields));
307         try {
308             ISODateTimeFormat.forFields(types, false, true);
309             fail();
310         } catch (IllegalArgumentException ex) {}
311     }
312 
313     //-----------------------------------------------------------------------
314     //-----------------------------------------------------------------------
315     //-----------------------------------------------------------------------
316     public void testForFields_weekBased_YWD() {
317         DateTimeFieldType[] fields = new DateTimeFieldType[] {
318                 DateTimeFieldType.weekyear(),
319                 DateTimeFieldType.weekOfWeekyear(),
320                 DateTimeFieldType.dayOfWeek(),
321         };
322         int[] values = new int[] {2005, 8, 5};
323         List types = new ArrayList(Arrays.asList(fields));
324         DateTimeFormatter f = ISODateTimeFormat.forFields(types, true, true);
325         assertEquals("2005-W08-5", f.print(new Partial(fields, values)));
326         assertEquals(0, types.size());
327         
328         types = new ArrayList(Arrays.asList(fields));
329         f = ISODateTimeFormat.forFields(types, true, false);
330         assertEquals("2005-W08-5", f.print(new Partial(fields, values)));
331         assertEquals(0, types.size());
332         
333         types = new ArrayList(Arrays.asList(fields));
334         f = ISODateTimeFormat.forFields(types, false, true);
335         assertEquals("2005W085", f.print(new Partial(fields, values)));
336         assertEquals(0, types.size());
337         
338         types = new ArrayList(Arrays.asList(fields));
339         f = ISODateTimeFormat.forFields(types, false, false);
340         assertEquals("2005W085", f.print(new Partial(fields, values)));
341         assertEquals(0, types.size());
342     }
343 
344     //-----------------------------------------------------------------------
345     public void testForFields_weekBased_Y() {
346         DateTimeFieldType[] fields = new DateTimeFieldType[] {
347                 DateTimeFieldType.weekyear(),
348         };
349         int[] values = new int[] {2005};
350         List types = new ArrayList(Arrays.asList(fields));
351         DateTimeFormatter f = ISODateTimeFormat.forFields(types, true, true);
352         assertEquals("2005", f.print(new Partial(fields, values)));
353         assertEquals(0, types.size());
354         
355         types = new ArrayList(Arrays.asList(fields));
356         f = ISODateTimeFormat.forFields(types, true, false);
357         assertEquals("2005", f.print(new Partial(fields, values)));
358         assertEquals(0, types.size());
359         
360         types = new ArrayList(Arrays.asList(fields));
361         f = ISODateTimeFormat.forFields(types, false, true);
362         assertEquals("2005", f.print(new Partial(fields, values)));
363         assertEquals(0, types.size());
364         
365         types = new ArrayList(Arrays.asList(fields));
366         f = ISODateTimeFormat.forFields(types, false, false);
367         assertEquals("2005", f.print(new Partial(fields, values)));
368         assertEquals(0, types.size());
369     }
370 
371     //-----------------------------------------------------------------------
372     public void testForFields_weekBased_W() {
373         DateTimeFieldType[] fields = new DateTimeFieldType[] {
374                 DateTimeFieldType.weekOfWeekyear(),
375         };
376         int[] values = new int[] {8};
377         List types = new ArrayList(Arrays.asList(fields));
378         DateTimeFormatter f = ISODateTimeFormat.forFields(types, true, true);
379         assertEquals("-W08", f.print(new Partial(fields, values)));
380         assertEquals(0, types.size());
381         
382         types = new ArrayList(Arrays.asList(fields));
383         f = ISODateTimeFormat.forFields(types, true, false);
384         assertEquals("-W08", f.print(new Partial(fields, values)));
385         assertEquals(0, types.size());
386         
387         types = new ArrayList(Arrays.asList(fields));
388         f = ISODateTimeFormat.forFields(types, false, true);
389         assertEquals("-W08", f.print(new Partial(fields, values)));
390         assertEquals(0, types.size());
391         
392         types = new ArrayList(Arrays.asList(fields));
393         f = ISODateTimeFormat.forFields(types, false, false);
394         assertEquals("-W08", f.print(new Partial(fields, values)));
395         assertEquals(0, types.size());
396     }
397 
398     //-----------------------------------------------------------------------
399     public void testForFields_weekBased_D() {
400         DateTimeFieldType[] fields = new DateTimeFieldType[] {
401                 DateTimeFieldType.dayOfWeek(),
402         };
403         int[] values = new int[] {5};
404         List types = new ArrayList(Arrays.asList(fields));
405         DateTimeFormatter f = ISODateTimeFormat.forFields(types, true, true);
406         assertEquals("-W-5", f.print(new Partial(fields, values)));
407         assertEquals(0, types.size());
408         
409         types = new ArrayList(Arrays.asList(fields));
410         f = ISODateTimeFormat.forFields(types, true, false);
411         assertEquals("-W-5", f.print(new Partial(fields, values)));
412         assertEquals(0, types.size());
413         
414         types = new ArrayList(Arrays.asList(fields));
415         f = ISODateTimeFormat.forFields(types, false, true);
416         assertEquals("-W-5", f.print(new Partial(fields, values)));
417         assertEquals(0, types.size());
418         
419         types = new ArrayList(Arrays.asList(fields));
420         f = ISODateTimeFormat.forFields(types, false, false);
421         assertEquals("-W-5", f.print(new Partial(fields, values)));
422         assertEquals(0, types.size());
423     }
424 
425     //-----------------------------------------------------------------------
426     public void testForFields_weekBased_YW() {
427         DateTimeFieldType[] fields = new DateTimeFieldType[] {
428                 DateTimeFieldType.weekyear(),
429                 DateTimeFieldType.weekOfWeekyear(),
430         };
431         int[] values = new int[] {2005, 8};
432         List types = new ArrayList(Arrays.asList(fields));
433         DateTimeFormatter f = ISODateTimeFormat.forFields(types, true, true);
434         assertEquals("2005-W08", f.print(new Partial(fields, values)));
435         assertEquals(0, types.size());
436         
437         types = new ArrayList(Arrays.asList(fields));
438         f = ISODateTimeFormat.forFields(types, true, false);
439         assertEquals("2005-W08", f.print(new Partial(fields, values)));
440         assertEquals(0, types.size());
441         
442         types = new ArrayList(Arrays.asList(fields));
443         f = ISODateTimeFormat.forFields(types, false, true);
444         assertEquals("2005W08", f.print(new Partial(fields, values)));
445         assertEquals(0, types.size());
446         
447         types = new ArrayList(Arrays.asList(fields));
448         f = ISODateTimeFormat.forFields(types, false, false);
449         assertEquals("2005W08", f.print(new Partial(fields, values)));
450         assertEquals(0, types.size());
451     }
452 
453     //-----------------------------------------------------------------------
454     public void testForFields_weekBased_WD() {
455         DateTimeFieldType[] fields = new DateTimeFieldType[] {
456                 DateTimeFieldType.weekOfWeekyear(),
457                 DateTimeFieldType.dayOfWeek(),
458         };
459         int[] values = new int[] {8, 5};
460         List types = new ArrayList(Arrays.asList(fields));
461         DateTimeFormatter f = ISODateTimeFormat.forFields(types, true, true);
462         assertEquals("-W08-5", f.print(new Partial(fields, values)));
463         assertEquals(0, types.size());
464         
465         types = new ArrayList(Arrays.asList(fields));
466         f = ISODateTimeFormat.forFields(types, true, false);
467         assertEquals("-W08-5", f.print(new Partial(fields, values)));
468         assertEquals(0, types.size());
469         
470         types = new ArrayList(Arrays.asList(fields));
471         f = ISODateTimeFormat.forFields(types, false, true);
472         assertEquals("-W085", f.print(new Partial(fields, values)));
473         assertEquals(0, types.size());
474         
475         types = new ArrayList(Arrays.asList(fields));
476         f = ISODateTimeFormat.forFields(types, false, false);
477         assertEquals("-W085", f.print(new Partial(fields, values)));
478         assertEquals(0, types.size());
479     }
480 
481     //-----------------------------------------------------------------------
482     public void testForFields_weekBased_YD() {
483         DateTimeFieldType[] fields = new DateTimeFieldType[] {
484                 DateTimeFieldType.weekyear(),
485                 DateTimeFieldType.dayOfWeek(),
486         };
487         int[] values = new int[] {2005, 5};
488         List types = new ArrayList(Arrays.asList(fields));
489         DateTimeFormatter f = ISODateTimeFormat.forFields(types, true, false);
490         assertEquals("2005-W-5", f.print(new Partial(fields, values)));
491         assertEquals(0, types.size());
492         
493         types = new ArrayList(Arrays.asList(fields));
494         f = ISODateTimeFormat.forFields(types, false, false);
495         assertEquals("2005W-5", f.print(new Partial(fields, values)));
496         assertEquals(0, types.size());
497         
498         types = new ArrayList(Arrays.asList(fields));
499         try {
500             ISODateTimeFormat.forFields(types, true, true);
501             fail();
502         } catch (IllegalArgumentException ex) {}
503         
504         types = new ArrayList(Arrays.asList(fields));
505         try {
506             ISODateTimeFormat.forFields(types, false, true);
507             fail();
508         } catch (IllegalArgumentException ex) {}
509     }
510 
511     //-----------------------------------------------------------------------
512     //-----------------------------------------------------------------------
513     //-----------------------------------------------------------------------
514     public void testForFields_ordinalBased_YD() {
515         DateTimeFieldType[] fields = new DateTimeFieldType[] {
516                 DateTimeFieldType.year(),
517                 DateTimeFieldType.dayOfYear(),
518         };
519         int[] values = new int[] {2005, 177};
520         List types = new ArrayList(Arrays.asList(fields));
521         DateTimeFormatter f = ISODateTimeFormat.forFields(types, true, true);
522         assertEquals("2005-177", f.print(new Partial(fields, values)));
523         assertEquals(0, types.size());
524         
525         types = new ArrayList(Arrays.asList(fields));
526         f = ISODateTimeFormat.forFields(types, true, false);
527         assertEquals("2005-177", f.print(new Partial(fields, values)));
528         assertEquals(0, types.size());
529         
530         types = new ArrayList(Arrays.asList(fields));
531         f = ISODateTimeFormat.forFields(types, false, true);
532         assertEquals("2005177", f.print(new Partial(fields, values)));
533         assertEquals(0, types.size());
534         
535         types = new ArrayList(Arrays.asList(fields));
536         f = ISODateTimeFormat.forFields(types, false, false);
537         assertEquals("2005177", f.print(new Partial(fields, values)));
538         assertEquals(0, types.size());
539     }
540 
541     //-----------------------------------------------------------------------
542     public void testForFields_ordinalBased_Y() {
543         DateTimeFieldType[] fields = new DateTimeFieldType[] {
544                 DateTimeFieldType.year(),
545         };
546         int[] values = new int[] {2005};
547         List types = new ArrayList(Arrays.asList(fields));
548         DateTimeFormatter f = ISODateTimeFormat.forFields(types, true, true);
549         assertEquals("2005", f.print(new Partial(fields, values)));
550         assertEquals(0, types.size());
551         
552         types = new ArrayList(Arrays.asList(fields));
553         f = ISODateTimeFormat.forFields(types, true, false);
554         assertEquals("2005", f.print(new Partial(fields, values)));
555         assertEquals(0, types.size());
556         
557         types = new ArrayList(Arrays.asList(fields));
558         f = ISODateTimeFormat.forFields(types, false, true);
559         assertEquals("2005", f.print(new Partial(fields, values)));
560         assertEquals(0, types.size());
561         
562         types = new ArrayList(Arrays.asList(fields));
563         f = ISODateTimeFormat.forFields(types, false, false);
564         assertEquals("2005", f.print(new Partial(fields, values)));
565         assertEquals(0, types.size());
566     }
567 
568     //-----------------------------------------------------------------------
569     public void testForFields_ordinalBased_D() {
570         DateTimeFieldType[] fields = new DateTimeFieldType[] {
571                 DateTimeFieldType.dayOfYear(),
572         };
573         int[] values = new int[] {177};
574         List types = new ArrayList(Arrays.asList(fields));
575         DateTimeFormatter f = ISODateTimeFormat.forFields(types, true, true);
576         assertEquals("-177", f.print(new Partial(fields, values)));
577         assertEquals(0, types.size());
578         
579         types = new ArrayList(Arrays.asList(fields));
580         f = ISODateTimeFormat.forFields(types, true, false);
581         assertEquals("-177", f.print(new Partial(fields, values)));
582         assertEquals(0, types.size());
583         
584         types = new ArrayList(Arrays.asList(fields));
585         f = ISODateTimeFormat.forFields(types, false, true);
586         assertEquals("-177", f.print(new Partial(fields, values)));
587         assertEquals(0, types.size());
588         
589         types = new ArrayList(Arrays.asList(fields));
590         f = ISODateTimeFormat.forFields(types, false, false);
591         assertEquals("-177", f.print(new Partial(fields, values)));
592         assertEquals(0, types.size());
593     }
594 
595     //-----------------------------------------------------------------------
596     //-----------------------------------------------------------------------
597     //-----------------------------------------------------------------------
598     public void testForFields_time_HMSm() {
599         DateTimeFieldType[] fields = new DateTimeFieldType[] {
600                 DateTimeFieldType.hourOfDay(),
601                 DateTimeFieldType.minuteOfHour(),
602                 DateTimeFieldType.secondOfMinute(),
603                 DateTimeFieldType.millisOfSecond(),
604         };
605         int[] values = new int[] {10, 20, 30, 40};
606         List types = new ArrayList(Arrays.asList(fields));
607         DateTimeFormatter f = ISODateTimeFormat.forFields(types, true, true);
608         assertEquals("10:20:30.040", f.print(new Partial(fields, values)));
609         assertEquals(0, types.size());
610         
611         types = new ArrayList(Arrays.asList(fields));
612         f = ISODateTimeFormat.forFields(types, true, false);
613         assertEquals("10:20:30.040", f.print(new Partial(fields, values)));
614         assertEquals(0, types.size());
615         
616         types = new ArrayList(Arrays.asList(fields));
617         f = ISODateTimeFormat.forFields(types, false, true);
618         assertEquals("102030.040", f.print(new Partial(fields, values)));
619         assertEquals(0, types.size());
620         
621         types = new ArrayList(Arrays.asList(fields));
622         f = ISODateTimeFormat.forFields(types, false, false);
623         assertEquals("102030.040", f.print(new Partial(fields, values)));
624         assertEquals(0, types.size());
625     }
626 
627     //-----------------------------------------------------------------------
628     public void testForFields_time_HMS() {
629         DateTimeFieldType[] fields = new DateTimeFieldType[] {
630                 DateTimeFieldType.hourOfDay(),
631                 DateTimeFieldType.minuteOfHour(),
632                 DateTimeFieldType.secondOfMinute(),
633         };
634         int[] values = new int[] {10, 20, 30};
635         List types = new ArrayList(Arrays.asList(fields));
636         DateTimeFormatter f = ISODateTimeFormat.forFields(types, true, true);
637         assertEquals("10:20:30", f.print(new Partial(fields, values)));
638         assertEquals(0, types.size());
639         
640         types = new ArrayList(Arrays.asList(fields));
641         f = ISODateTimeFormat.forFields(types, true, false);
642         assertEquals("10:20:30", f.print(new Partial(fields, values)));
643         assertEquals(0, types.size());
644         
645         types = new ArrayList(Arrays.asList(fields));
646         f = ISODateTimeFormat.forFields(types, false, true);
647         assertEquals("102030", f.print(new Partial(fields, values)));
648         assertEquals(0, types.size());
649         
650         types = new ArrayList(Arrays.asList(fields));
651         f = ISODateTimeFormat.forFields(types, false, false);
652         assertEquals("102030", f.print(new Partial(fields, values)));
653         assertEquals(0, types.size());
654     }
655 
656     //-----------------------------------------------------------------------
657     public void testForFields_time_HM() {
658         DateTimeFieldType[] fields = new DateTimeFieldType[] {
659                 DateTimeFieldType.hourOfDay(),
660                 DateTimeFieldType.minuteOfHour(),
661         };
662         int[] values = new int[] {10, 20};
663         List types = new ArrayList(Arrays.asList(fields));
664         DateTimeFormatter f = ISODateTimeFormat.forFields(types, true, true);
665         assertEquals("10:20", f.print(new Partial(fields, values)));
666         assertEquals(0, types.size());
667         
668         types = new ArrayList(Arrays.asList(fields));
669         f = ISODateTimeFormat.forFields(types, true, false);
670         assertEquals("10:20", f.print(new Partial(fields, values)));
671         assertEquals(0, types.size());
672         
673         types = new ArrayList(Arrays.asList(fields));
674         f = ISODateTimeFormat.forFields(types, false, true);
675         assertEquals("1020", f.print(new Partial(fields, values)));
676         assertEquals(0, types.size());
677         
678         types = new ArrayList(Arrays.asList(fields));
679         f = ISODateTimeFormat.forFields(types, false, false);
680         assertEquals("1020", f.print(new Partial(fields, values)));
681         assertEquals(0, types.size());
682     }
683 
684     //-----------------------------------------------------------------------
685     public void testForFields_time_H() {
686         DateTimeFieldType[] fields = new DateTimeFieldType[] {
687                 DateTimeFieldType.hourOfDay(),
688         };
689         int[] values = new int[] {10};
690         List types = new ArrayList(Arrays.asList(fields));
691         DateTimeFormatter f = ISODateTimeFormat.forFields(types, true, true);
692         assertEquals("10", f.print(new Partial(fields, values)));
693         assertEquals(0, types.size());
694         
695         types = new ArrayList(Arrays.asList(fields));
696         f = ISODateTimeFormat.forFields(types, true, false);
697         assertEquals("10", f.print(new Partial(fields, values)));
698         assertEquals(0, types.size());
699         
700         types = new ArrayList(Arrays.asList(fields));
701         f = ISODateTimeFormat.forFields(types, false, true);
702         assertEquals("10", f.print(new Partial(fields, values)));
703         assertEquals(0, types.size());
704         
705         types = new ArrayList(Arrays.asList(fields));
706         f = ISODateTimeFormat.forFields(types, false, false);
707         assertEquals("10", f.print(new Partial(fields, values)));
708         assertEquals(0, types.size());
709     }
710 
711     //-----------------------------------------------------------------------
712     public void testForFields_time_MSm() {
713         DateTimeFieldType[] fields = new DateTimeFieldType[] {
714                 DateTimeFieldType.minuteOfHour(),
715                 DateTimeFieldType.secondOfMinute(),
716                 DateTimeFieldType.millisOfSecond(),
717         };
718         int[] values = new int[] {20, 30, 40};
719         List types = new ArrayList(Arrays.asList(fields));
720         DateTimeFormatter f = ISODateTimeFormat.forFields(types, true, true);
721         assertEquals("-20:30.040", f.print(new Partial(fields, values)));
722         assertEquals(0, types.size());
723         
724         types = new ArrayList(Arrays.asList(fields));
725         f = ISODateTimeFormat.forFields(types, true, false);
726         assertEquals("-20:30.040", f.print(new Partial(fields, values)));
727         assertEquals(0, types.size());
728         
729         types = new ArrayList(Arrays.asList(fields));
730         f = ISODateTimeFormat.forFields(types, false, true);
731         assertEquals("-2030.040", f.print(new Partial(fields, values)));
732         assertEquals(0, types.size());
733         
734         types = new ArrayList(Arrays.asList(fields));
735         f = ISODateTimeFormat.forFields(types, false, false);
736         assertEquals("-2030.040", f.print(new Partial(fields, values)));
737         assertEquals(0, types.size());
738     }
739 
740     //-----------------------------------------------------------------------
741     public void testForFields_time_MS() {
742         DateTimeFieldType[] fields = new DateTimeFieldType[] {
743                 DateTimeFieldType.minuteOfHour(),
744                 DateTimeFieldType.secondOfMinute(),
745         };
746         int[] values = new int[] {20, 30};
747         List types = new ArrayList(Arrays.asList(fields));
748         DateTimeFormatter f = ISODateTimeFormat.forFields(types, true, true);
749         assertEquals("-20:30", f.print(new Partial(fields, values)));
750         assertEquals(0, types.size());
751         
752         types = new ArrayList(Arrays.asList(fields));
753         f = ISODateTimeFormat.forFields(types, true, false);
754         assertEquals("-20:30", f.print(new Partial(fields, values)));
755         assertEquals(0, types.size());
756         
757         types = new ArrayList(Arrays.asList(fields));
758         f = ISODateTimeFormat.forFields(types, false, true);
759         assertEquals("-2030", f.print(new Partial(fields, values)));
760         assertEquals(0, types.size());
761         
762         types = new ArrayList(Arrays.asList(fields));
763         f = ISODateTimeFormat.forFields(types, false, false);
764         assertEquals("-2030", f.print(new Partial(fields, values)));
765         assertEquals(0, types.size());
766     }
767 
768     //-----------------------------------------------------------------------
769     public void testForFields_time_M() {
770         DateTimeFieldType[] fields = new DateTimeFieldType[] {
771                 DateTimeFieldType.minuteOfHour(),
772         };
773         int[] values = new int[] {20};
774         List types = new ArrayList(Arrays.asList(fields));
775         DateTimeFormatter f = ISODateTimeFormat.forFields(types, true, true);
776         assertEquals("-20", f.print(new Partial(fields, values)));
777         assertEquals(0, types.size());
778         
779         types = new ArrayList(Arrays.asList(fields));
780         f = ISODateTimeFormat.forFields(types, true, false);
781         assertEquals("-20", f.print(new Partial(fields, values)));
782         assertEquals(0, types.size());
783         
784         types = new ArrayList(Arrays.asList(fields));
785         f = ISODateTimeFormat.forFields(types, false, true);
786         assertEquals("-20", f.print(new Partial(fields, values)));
787         assertEquals(0, types.size());
788         
789         types = new ArrayList(Arrays.asList(fields));
790         f = ISODateTimeFormat.forFields(types, false, false);
791         assertEquals("-20", f.print(new Partial(fields, values)));
792         assertEquals(0, types.size());
793     }
794 
795     //-----------------------------------------------------------------------
796     public void testForFields_time_Sm() {
797         DateTimeFieldType[] fields = new DateTimeFieldType[] {
798                 DateTimeFieldType.secondOfMinute(),
799                 DateTimeFieldType.millisOfSecond(),
800         };
801         int[] values = new int[] {30, 40};
802         List types = new ArrayList(Arrays.asList(fields));
803         DateTimeFormatter f = ISODateTimeFormat.forFields(types, true, true);
804         assertEquals("--30.040", f.print(new Partial(fields, values)));
805         assertEquals(0, types.size());
806         
807         types = new ArrayList(Arrays.asList(fields));
808         f = ISODateTimeFormat.forFields(types, true, false);
809         assertEquals("--30.040", f.print(new Partial(fields, values)));
810         assertEquals(0, types.size());
811         
812         types = new ArrayList(Arrays.asList(fields));
813         f = ISODateTimeFormat.forFields(types, false, true);
814         assertEquals("--30.040", f.print(new Partial(fields, values)));
815         assertEquals(0, types.size());
816         
817         types = new ArrayList(Arrays.asList(fields));
818         f = ISODateTimeFormat.forFields(types, false, false);
819         assertEquals("--30.040", f.print(new Partial(fields, values)));
820         assertEquals(0, types.size());
821     }
822 
823     //-----------------------------------------------------------------------
824     public void testForFields_time_S() {
825         DateTimeFieldType[] fields = new DateTimeFieldType[] {
826                 DateTimeFieldType.secondOfMinute(),
827         };
828         int[] values = new int[] {30};
829         List types = new ArrayList(Arrays.asList(fields));
830         DateTimeFormatter f = ISODateTimeFormat.forFields(types, true, true);
831         assertEquals("--30", f.print(new Partial(fields, values)));
832         assertEquals(0, types.size());
833         
834         types = new ArrayList(Arrays.asList(fields));
835         f = ISODateTimeFormat.forFields(types, true, false);
836         assertEquals("--30", f.print(new Partial(fields, values)));
837         assertEquals(0, types.size());
838         
839         types = new ArrayList(Arrays.asList(fields));
840         f = ISODateTimeFormat.forFields(types, false, true);
841         assertEquals("--30", f.print(new Partial(fields, values)));
842         assertEquals(0, types.size());
843         
844         types = new ArrayList(Arrays.asList(fields));
845         f = ISODateTimeFormat.forFields(types, false, false);
846         assertEquals("--30", f.print(new Partial(fields, values)));
847         assertEquals(0, types.size());
848     }
849 
850     //-----------------------------------------------------------------------
851     public void testForFields_time_m() {
852         DateTimeFieldType[] fields = new DateTimeFieldType[] {
853                 DateTimeFieldType.millisOfSecond(),
854         };
855         int[] values = new int[] {40};
856         List types = new ArrayList(Arrays.asList(fields));
857         DateTimeFormatter f = ISODateTimeFormat.forFields(types, true, false);
858         assertEquals("---.040", f.print(new Partial(fields, values)));
859         assertEquals(0, types.size());
860         
861         types = new ArrayList(Arrays.asList(fields));
862         f = ISODateTimeFormat.forFields(types, false, false);
863         assertEquals("---.040", f.print(new Partial(fields, values)));
864         assertEquals(0, types.size());
865         
866         types = new ArrayList(Arrays.asList(fields));
867         try {
868             ISODateTimeFormat.forFields(types, true, true);
869             fail();
870         } catch (IllegalArgumentException ex) {}
871         
872         types = new ArrayList(Arrays.asList(fields));
873         try {
874             ISODateTimeFormat.forFields(types, false, true);
875             fail();
876         } catch (IllegalArgumentException ex) {}
877     }
878 
879     //-----------------------------------------------------------------------
880     public void testForFields_time_Hm() {
881         DateTimeFieldType[] fields = new DateTimeFieldType[] {
882                 DateTimeFieldType.hourOfDay(),
883                 DateTimeFieldType.millisOfSecond(),
884         };
885         int[] values = new int[] {10, 40};
886         List types = new ArrayList(Arrays.asList(fields));
887         DateTimeFormatter f = ISODateTimeFormat.forFields(types, true, false);
888         assertEquals("10--.040", f.print(new Partial(fields, values)));
889         assertEquals(0, types.size());
890         
891         types = new ArrayList(Arrays.asList(fields));
892         f = ISODateTimeFormat.forFields(types, false, false);
893         assertEquals("10--.040", f.print(new Partial(fields, values)));
894         assertEquals(0, types.size());
895         
896         types = new ArrayList(Arrays.asList(fields));
897         try {
898             ISODateTimeFormat.forFields(types, true, true);
899             fail();
900         } catch (IllegalArgumentException ex) {}
901         
902         types = new ArrayList(Arrays.asList(fields));
903         try {
904             ISODateTimeFormat.forFields(types, false, true);
905             fail();
906         } catch (IllegalArgumentException ex) {}
907     }
908 
909     //-----------------------------------------------------------------------
910     public void testForFields_time_HS() {
911         DateTimeFieldType[] fields = new DateTimeFieldType[] {
912                 DateTimeFieldType.hourOfDay(),
913                 DateTimeFieldType.secondOfMinute(),
914         };
915         int[] values = new int[] {10, 30};
916         List types = new ArrayList(Arrays.asList(fields));
917         DateTimeFormatter f = ISODateTimeFormat.forFields(types, true, false);
918         assertEquals("10-30", f.print(new Partial(fields, values)));
919         assertEquals(0, types.size());
920         
921         types = new ArrayList(Arrays.asList(fields));
922         f = ISODateTimeFormat.forFields(types, false, false);
923         assertEquals("10-30", f.print(new Partial(fields, values)));
924         assertEquals(0, types.size());
925         
926         types = new ArrayList(Arrays.asList(fields));
927         try {
928             ISODateTimeFormat.forFields(types, true, true);
929             fail();
930         } catch (IllegalArgumentException ex) {}
931         
932         types = new ArrayList(Arrays.asList(fields));
933         try {
934             ISODateTimeFormat.forFields(types, false, true);
935             fail();
936         } catch (IllegalArgumentException ex) {}
937     }
938 
939     //-----------------------------------------------------------------------
940     public void testForFields_time_Mm() {
941         DateTimeFieldType[] fields = new DateTimeFieldType[] {
942                 DateTimeFieldType.minuteOfHour(),
943                 DateTimeFieldType.millisOfSecond(),
944         };
945         int[] values = new int[] {20, 40};
946         List types = new ArrayList(Arrays.asList(fields));
947         DateTimeFormatter f = ISODateTimeFormat.forFields(types, true, false);
948         assertEquals("-20-.040", f.print(new Partial(fields, values)));
949         assertEquals(0, types.size());
950         
951         types = new ArrayList(Arrays.asList(fields));
952         f = ISODateTimeFormat.forFields(types, false, false);
953         assertEquals("-20-.040", f.print(new Partial(fields, values)));
954         assertEquals(0, types.size());
955         
956         types = new ArrayList(Arrays.asList(fields));
957         try {
958             ISODateTimeFormat.forFields(types, true, true);
959             fail();
960         } catch (IllegalArgumentException ex) {}
961         
962         types = new ArrayList(Arrays.asList(fields));
963         try {
964             ISODateTimeFormat.forFields(types, false, true);
965             fail();
966         } catch (IllegalArgumentException ex) {}
967     }
968 
969     //-----------------------------------------------------------------------
970     public void testForFields_time_HSm() {
971         DateTimeFieldType[] fields = new DateTimeFieldType[] {
972                 DateTimeFieldType.hourOfDay(),
973                 DateTimeFieldType.secondOfMinute(),
974                 DateTimeFieldType.millisOfSecond(),
975         };
976         int[] values = new int[] {10, 30, 40};
977         List types = new ArrayList(Arrays.asList(fields));
978         DateTimeFormatter f = ISODateTimeFormat.forFields(types, true, false);
979         assertEquals("10-30.040", f.print(new Partial(fields, values)));
980         assertEquals(0, types.size());
981         
982         types = new ArrayList(Arrays.asList(fields));
983         f = ISODateTimeFormat.forFields(types, false, false);
984         assertEquals("10-30.040", f.print(new Partial(fields, values)));
985         assertEquals(0, types.size());
986         
987         types = new ArrayList(Arrays.asList(fields));
988         try {
989             ISODateTimeFormat.forFields(types, true, true);
990             fail();
991         } catch (IllegalArgumentException ex) {}
992         
993         types = new ArrayList(Arrays.asList(fields));
994         try {
995             ISODateTimeFormat.forFields(types, false, true);
996             fail();
997         } catch (IllegalArgumentException ex) {}
998     }
999 
1000     //-----------------------------------------------------------------------
1001     public void testForFields_time_HMm() {
1002         DateTimeFieldType[] fields = new DateTimeFieldType[] {
1003                 DateTimeFieldType.hourOfDay(),
1004                 DateTimeFieldType.minuteOfHour(),
1005                 DateTimeFieldType.millisOfSecond(),
1006         };
1007         int[] values = new int[] {10, 20, 40};
1008         List types = new ArrayList(Arrays.asList(fields));
1009         DateTimeFormatter f = ISODateTimeFormat.forFields(types, true, false);
1010         assertEquals("10:20-.040", f.print(new Partial(fields, values)));
1011         assertEquals(0, types.size());
1012         
1013         types = new ArrayList(Arrays.asList(fields));
1014         f = ISODateTimeFormat.forFields(types, false, false);
1015         assertEquals("1020-.040", f.print(new Partial(fields, values)));
1016         assertEquals(0, types.size());
1017         
1018         types = new ArrayList(Arrays.asList(fields));
1019         try {
1020             ISODateTimeFormat.forFields(types, true, true);
1021             fail();
1022         } catch (IllegalArgumentException ex) {}
1023         
1024         types = new ArrayList(Arrays.asList(fields));
1025         try {
1026             ISODateTimeFormat.forFields(types, false, true);
1027             fail();
1028         } catch (IllegalArgumentException ex) {}
1029     }
1030 
1031     //-----------------------------------------------------------------------
1032     //-----------------------------------------------------------------------
1033     //-----------------------------------------------------------------------
1034     public void testForFields_datetime_YMDH() {
1035         DateTimeFieldType[] fields = new DateTimeFieldType[] {
1036                 DateTimeFieldType.year(),
1037                 DateTimeFieldType.monthOfYear(),
1038                 DateTimeFieldType.dayOfMonth(),
1039                 DateTimeFieldType.hourOfDay(),
1040         };
1041         int[] values = new int[] {2005, 6, 25, 12};
1042         List types = new ArrayList(Arrays.asList(fields));
1043         DateTimeFormatter f = ISODateTimeFormat.forFields(types, true, true);
1044         assertEquals("2005-06-25T12", f.print(new Partial(fields, values)));
1045         assertEquals(0, types.size());
1046         
1047         types = new ArrayList(Arrays.asList(fields));
1048         f = ISODateTimeFormat.forFields(types, true, false);
1049         assertEquals("2005-06-25T12", f.print(new Partial(fields, values)));
1050         assertEquals(0, types.size());
1051         
1052         types = new ArrayList(Arrays.asList(fields));
1053         f = ISODateTimeFormat.forFields(types, false, true);
1054         assertEquals("20050625T12", f.print(new Partial(fields, values)));
1055         assertEquals(0, types.size());
1056         
1057         types = new ArrayList(Arrays.asList(fields));
1058         f = ISODateTimeFormat.forFields(types, false, false);
1059         assertEquals("20050625T12", f.print(new Partial(fields, values)));
1060         assertEquals(0, types.size());
1061     }
1062 
1063     //-----------------------------------------------------------------------
1064     public void testForFields_datetime_DH() {
1065         DateTimeFieldType[] fields = new DateTimeFieldType[] {
1066                 DateTimeFieldType.dayOfMonth(),
1067                 DateTimeFieldType.hourOfDay(),
1068         };
1069         int[] values = new int[] {25, 12};
1070         List types = new ArrayList(Arrays.asList(fields));
1071         DateTimeFormatter f = ISODateTimeFormat.forFields(types, true, true);
1072         assertEquals("---25T12", f.print(new Partial(fields, values)));
1073         assertEquals(0, types.size());
1074         
1075         types = new ArrayList(Arrays.asList(fields));
1076         f = ISODateTimeFormat.forFields(types, true, false);
1077         assertEquals("---25T12", f.print(new Partial(fields, values)));
1078         assertEquals(0, types.size());
1079         
1080         types = new ArrayList(Arrays.asList(fields));
1081         f = ISODateTimeFormat.forFields(types, false, true);
1082         assertEquals("---25T12", f.print(new Partial(fields, values)));
1083         assertEquals(0, types.size());
1084         
1085         types = new ArrayList(Arrays.asList(fields));
1086         f = ISODateTimeFormat.forFields(types, false, false);
1087         assertEquals("---25T12", f.print(new Partial(fields, values)));
1088         assertEquals(0, types.size());
1089     }
1090 
1091     //-----------------------------------------------------------------------
1092     public void testForFields_datetime_YH() {
1093         DateTimeFieldType[] fields = new DateTimeFieldType[] {
1094                 DateTimeFieldType.year(),
1095                 DateTimeFieldType.hourOfDay(),
1096         };
1097         int[] values = new int[] {2005, 12};
1098         List types = new ArrayList(Arrays.asList(fields));
1099         DateTimeFormatter f = ISODateTimeFormat.forFields(types, true, false);
1100         assertEquals("2005T12", f.print(new Partial(fields, values)));
1101         assertEquals(0, types.size());
1102         
1103         types = new ArrayList(Arrays.asList(fields));
1104         f = ISODateTimeFormat.forFields(types, false, false);
1105         assertEquals("2005T12", f.print(new Partial(fields, values)));
1106         assertEquals(0, types.size());
1107         
1108         types = new ArrayList(Arrays.asList(fields));
1109         try {
1110             ISODateTimeFormat.forFields(types, true, true);
1111             fail();
1112         } catch (IllegalArgumentException ex) {}
1113         
1114         types = new ArrayList(Arrays.asList(fields));
1115         try {
1116             ISODateTimeFormat.forFields(types, false, true);
1117             fail();
1118         } catch (IllegalArgumentException ex) {}
1119     }
1120 
1121     //-----------------------------------------------------------------------
1122     public void testForFields_datetime_DM() {
1123         DateTimeFieldType[] fields = new DateTimeFieldType[] {
1124                 DateTimeFieldType.dayOfMonth(),
1125                 DateTimeFieldType.minuteOfHour(),
1126         };
1127         int[] values = new int[] {25, 20};
1128         List types = new ArrayList(Arrays.asList(fields));
1129         DateTimeFormatter f = ISODateTimeFormat.forFields(types, true, false);
1130         assertEquals("---25T-20", f.print(new Partial(fields, values)));
1131         assertEquals(0, types.size());
1132         
1133         types = new ArrayList(Arrays.asList(fields));
1134         f = ISODateTimeFormat.forFields(types, false, false);
1135         assertEquals("---25T-20", f.print(new Partial(fields, values)));
1136         assertEquals(0, types.size());
1137         
1138         types = new ArrayList(Arrays.asList(fields));
1139         try {
1140             ISODateTimeFormat.forFields(types, true, true);
1141             fail();
1142         } catch (IllegalArgumentException ex) {}
1143         
1144         types = new ArrayList(Arrays.asList(fields));
1145         try {
1146             ISODateTimeFormat.forFields(types, false, true);
1147             fail();
1148         } catch (IllegalArgumentException ex) {}
1149     }
1150 
1151 }