|
@@ -36,54 +36,72 @@ |
36 |
36 |
|
public void test_ContructorsAndToString() |
37 |
37 |
|
throws Exception |
38 |
38 |
|
{ |
39 |
|
- |
// Leap Day |
40 |
|
- |
chk( new CalendarYMD( 2004, 2, 29 ), "29 Feb 2004", "dMy", 2004, 2, 29 ); |
41 |
|
- |
// exception-exception Leap Day |
42 |
|
- |
chk( new CalendarYMD( 2000, 2, 29 ), "29 Feb 2000", "dMy", 2000, 2, 29 ); |
|
39 |
+ |
chkYMD( "dd MMM yyyy", "dMy", 2004, 2, 29, "29 Feb 2004" ); // Leap Day |
|
40 |
+ |
chkYMD( "dd MMM yyyy", "dMy", 2000, 2, 29, "29 Feb 2000" ); // exception-exception Leap Day |
43 |
41 |
|
|
44 |
|
- |
chk( new CalendarYMD( 1957, 1, 4 ), "04 Jan 1957", "dMy", 1957, 1, 4 ); |
45 |
|
- |
chk( "yy", 1996, "96", "y", 1996, 0, 0 ); |
46 |
|
- |
chk( "/yy", 1996, "/96", "y", 1996, 0, 0 ); |
47 |
|
- |
chk( "/ y:", 1996, "/ 1996:", "y", 1996, 0, 0 ); |
48 |
|
- |
chk( "/ yyy:", 1996, "/ 1996:", "y", 1996, 0, 0 ); |
49 |
|
- |
chk( "MM/dd/yy", 1957, 1, 4, "01/04/57", "Mdy", 1957, 1, 4 ); |
50 |
|
- |
chk( "init y/M/d fini", 1957, 1, 4, "init 1957/1/4 fini", "yMd", 1957, 1, 4 ); |
51 |
|
- |
chk( "dMMM", 1957, 1, 4, "4Jan", "dM", 1957, 1, 4 ); |
52 |
|
- |
chk( "dMMMyy", 1957, 1, 4, "4Jan57", "dMy", 1957, 1, 4 ); |
53 |
|
- |
chk( "dMMMyy", 1957, 1, 4, "4Jan57", "dMy", 1957, 1, 4 ); |
54 |
|
- |
chk( "d MMMM y", 1957, 1, 4, "4 January 1957", "dMy", 1957, 1, 4 ); |
55 |
|
- |
chk( "MMMMMM y", 1957, 1, "January 1957", "My", 1957, 1, 0 ); |
56 |
|
- |
chk( "MMMM d, y", 1957, 1, 4, "January 4, 1957", "Mdy", 1957, 1, 4 ); |
57 |
|
- |
chk( "(M/d/y) MMMM d", 1957, 1, 4, "(1/4/1957) January 4", "Mdy", 1957, 1, 4 ); |
58 |
|
- |
chk( "(M/d/y) ddMMM", 1957, 1, 4, "(1/4/1957) 04Jan", "Mdy", 1957, 1, 4 ); |
|
42 |
+ |
chkYMD( "dd MMM yyyy", "dMy", 1957, 1, 4, "04 Jan 1957" ); |
|
43 |
+ |
|
|
44 |
+ |
chkYMD( "MM/dd/yy", "Mdy", 1957, 1, 4, "01/04/57" ); |
|
45 |
+ |
chkYMD( "init y/M/d fini", "yMd", 1957, 1, 4, "init 1957/1/4 fini" ); |
|
46 |
+ |
chkYMD( "dMMM", "dM", 1957, 1, 4, "4Jan" ); |
|
47 |
+ |
chkYMD( "dMMMyy", "dMy", 1957, 1, 4, "4Jan57" ); |
|
48 |
+ |
chkYMD( "dMMMyy", "dMy", 1957, 1, 4, "4Jan57" ); |
|
49 |
+ |
chkYMD( "d MMMM y", "dMy", 1957, 1, 4, "4 January 1957" ); |
|
50 |
+ |
chkYMD( "MMMM d, y", "Mdy", 1957, 1, 4, "January 4, 1957" ); |
|
51 |
+ |
chkYMD( "(M/d/y) MMMM d", "Mdy", 1957, 1, 4, "(1/4/1957) January 4" ); |
|
52 |
+ |
chkYMD( "(M/d/y) ddMMM", "Mdy", 1957, 1, 4, "(1/4/1957) 04Jan" ); |
|
53 |
+ |
|
|
54 |
+ |
chkYM( "MMMMMM y", "My", 1957, 1, "January 1957" ); |
|
55 |
+ |
|
|
56 |
+ |
chkY( "yy", "y", 1996, "96" ); |
|
57 |
+ |
chkY( "/yy", "y", 1996, "/96" ); |
|
58 |
+ |
chkY( "/ y:", "y", 1996, "/ 1996:" ); |
|
59 |
+ |
chkY( "/ yyy:", "y", 1996, "/ 1996:" ); |
59 |
60 |
|
} |
60 |
61 |
|
|
61 |
|
- |
private void chk( String pDateFormat, int pYearSrc, String pToString, String pFieldOrder, int pYear, int pMonth, int pDay ) |
|
62 |
+ |
private void chkYMD( String pDateFormat, String pFieldOrder, int pYear, int pMonth, int pDay, String pToString ) |
62 |
63 |
|
{ |
63 |
|
- |
chk( new DateFormat( pDateFormat ), new CalendarY( pYearSrc ), pToString, pFieldOrder, pYear, pMonth, pDay ); |
|
64 |
+ |
chkYMD( new DateFormat( pDateFormat ), new CalendarYMD( pYear, pMonth, pDay ), pToString, pFieldOrder, pYear, pMonth, pDay ); |
64 |
65 |
|
} |
65 |
66 |
|
|
66 |
|
- |
private void chk( String pDateFormat, int pYearSrc, int pMonthSrc, String pToString, String pFieldOrder, int pYear, int pMonth, int pDay ) |
|
67 |
+ |
private void chkYM( String pDateFormat, String pFieldOrder, int pYear, int pMonth, String pToString ) |
67 |
68 |
|
{ |
68 |
|
- |
chk( new DateFormat( pDateFormat ), new CalendarYM( pYearSrc, pMonthSrc ), pToString, pFieldOrder, pYear, pMonth, pDay ); |
|
69 |
+ |
chkYM( new DateFormat( pDateFormat ), new CalendarYM( pYear, pMonth ), pToString, pFieldOrder, pYear, pMonth ); |
69 |
70 |
|
} |
70 |
71 |
|
|
71 |
|
- |
private void chk( String pDateFormat, int pYearSrc, int pMonthSrc, int pDaySrc, String pToString, String pFieldOrder, int pYear, int pMonth, int pDay ) |
|
72 |
+ |
private void chkY( String pDateFormat, String pFieldOrder, int pYear, String pToString ) |
72 |
73 |
|
{ |
73 |
|
- |
chk( new DateFormat( pDateFormat ), new CalendarYMD( pYearSrc, pMonthSrc, pDaySrc ), pToString, pFieldOrder, pYear, pMonth, pDay ); |
|
74 |
+ |
chkY( new DateFormat( pDateFormat ), new CalendarY( pYear ), pToString, pFieldOrder, pYear ); |
74 |
75 |
|
} |
75 |
76 |
|
|
76 |
|
- |
private void chk( CalendarAccessorY pDate, String pToString, String pFieldOrder, int pYear, int pMonth, int pDay ) |
|
77 |
+ |
private void chkYMD( DateFormat pFormat, CalendarAccessorYMD pDate, String pToString, String pFieldOrder, int pYear, int pMonth, int pDay ) |
77 |
78 |
|
{ |
78 |
|
- |
chk( pDate.getDateRes().getDateFormat(), pDate, pToString, pFieldOrder, pYear, pMonth, pDay ); |
|
79 |
+ |
assertEquals( pFieldOrder, pFormat.getFieldOrder() ); |
|
80 |
+ |
assertEquals( "Day", pDay, pDate.getDay() ); |
|
81 |
+ |
chkYMcommon( pFormat, pDate, pToString, pYear, pMonth ); |
79 |
82 |
|
} |
80 |
83 |
|
|
81 |
|
- |
private void chk( DateFormat pFormat, CalendarAccessorY pDate, String pToString, String pFieldOrder, int pYear, int pMonth, int pDay ) |
|
84 |
+ |
private void chkYM( DateFormat pFormat, CalendarAccessorYM pDate, String pToString, String pFieldOrder, int pYear, int pMonth ) |
82 |
85 |
|
{ |
83 |
86 |
|
assertEquals( pFieldOrder, pFormat.getFieldOrder() ); |
84 |
|
- |
assertEquals( "Year", pYear, pDate.getYear() ); |
|
87 |
+ |
chkYMcommon( pFormat, pDate, pToString, pYear, pMonth ); |
|
88 |
+ |
} |
|
89 |
+ |
|
|
90 |
+ |
private void chkY( DateFormat pFormat, CalendarAccessorY pDate, String pToString, String pFieldOrder, int pYear ) |
|
91 |
+ |
{ |
|
92 |
+ |
assertEquals( pFieldOrder, pFormat.getFieldOrder() ); |
|
93 |
+ |
chkYcommon( pFormat, pDate, pToString, pYear ); |
|
94 |
+ |
} |
|
95 |
+ |
|
|
96 |
+ |
private void chkYMcommon( DateFormat pFormat, CalendarAccessorYM pDate, String pToString, int pYear, int pMonth ) |
|
97 |
+ |
{ |
85 |
98 |
|
assertEquals( "Month", pMonth, pDate.getMonth() ); |
86 |
|
- |
assertEquals( "Day", pDay, pDate.getDay() ); |
|
99 |
+ |
chkYcommon( pFormat, pDate, pToString, pYear ); |
|
100 |
+ |
} |
|
101 |
+ |
|
|
102 |
+ |
private void chkYcommon( DateFormat pFormat, CalendarAccessorY pDate, String pToString, int pYear ) |
|
103 |
+ |
{ |
|
104 |
+ |
assertEquals( "Year", pYear, pDate.getYear() ); |
87 |
105 |
|
assertEquals( pToString, pFormat.format( pDate ) ); |
88 |
106 |
|
} |
89 |
107 |
|
} |