KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > joda > time > format > TestISODateTimeFormat_Fields


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 JavaDoc;
19 import java.util.Arrays JavaDoc;
20 import java.util.Collection JavaDoc;
21 import java.util.List JavaDoc;
22
23 import junit.framework.TestCase;
24 import junit.framework.TestSuite;
25
26 import org.joda.time.DateTimeFieldType;
27 import org.joda.time.Partial;
28
29 /**
30  * This class is a Junit unit test for ISODateTimeFormat.
31  *
32  * @author Stephen Colebourne
33  */

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