litesoft
@ 863
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 |
// This Source Code is in the Public Domain per: http://litesoft.org/License.txt package org.litesoft.core.simpletypes.temporal; import junit.framework.*; public class DateFormatTest extends TestCase { public static TestSuite suite() { return new TestSuite( DateFormatTest.class ); } public DateFormatTest( String name ) { super( name ); } public static void main( String[] args ) { junit.textui.TestRunner.run( suite() ); } public void test_FormatToDateResAndFieldOrder() { chkRT( "y", DateRes.ToYEAR ); chkRT( "yM", DateRes.ToMONTH ); chkRT( "yMd", DateRes.ToDAY ); } private void chkRT( String pFormatAndFieldOrder, DateRes pDateResExpected ) { DateFormat zFormat = new DateFormat( pFormatAndFieldOrder ); assertEquals( pDateResExpected, zFormat.getDateRes() ); } public void test_ContructorsAndToString() throws Exception { chkYMD( "dd MMM yyyy", "dMy", 2004, 2, 29, "29 Feb 2004" ); // Leap Day chkYMD( "dd MMM yyyy", "dMy", 2000, 2, 29, "29 Feb 2000" ); // exception-exception Leap Day chkYMD( "dd MMM yyyy", "dMy", 1957, 1, 4, "04 Jan 1957" ); chkYMD( "MM/dd/yy", "Mdy", 1957, 1, 4, "01/04/57" ); chkYMD( "init y/M/d fini", "yMd", 1957, 1, 4, "init 1957/1/4 fini" ); chkYMD( "dMMM", "dM", 1957, 1, 4, "4Jan" ); chkYMD( "dMMMyy", "dMy", 1957, 1, 4, "4Jan57" ); chkYMD( "dMMMyy", "dMy", 1957, 1, 4, "4Jan57" ); chkYMD( "d MMMM y", "dMy", 1957, 1, 4, "4 January 1957" ); chkYMD( "MMMM d, y", "Mdy", 1957, 1, 4, "January 4, 1957" ); chkYMD( "(M/d/y) MMMM d", "Mdy", 1957, 1, 4, "(1/4/1957) January 4" ); chkYMD( "(M/d/y) ddMMM", "Mdy", 1957, 1, 4, "(1/4/1957) 04Jan" ); chkYM( "MMMMMM y", "My", 1957, 1, "January 1957" ); chkY( "yy", "y", 1996, "96" ); chkY( "/yy", "y", 1996, "/96" ); chkY( "/ y:", "y", 1996, "/ 1996:" ); chkY( "/ yyy:", "y", 1996, "/ 1996:" ); } private void chkYMD( String pDateFormat, String pFieldOrder, int pYear, int pMonth, int pDay, String pToString ) { chkYMD( new DateFormat( pDateFormat ), new CalendarYMD( pYear, pMonth, pDay ), pToString, pFieldOrder, pYear, pMonth, pDay ); } private void chkYM( String pDateFormat, String pFieldOrder, int pYear, int pMonth, String pToString ) { chkYM( new DateFormat( pDateFormat ), new CalendarYM( pYear, pMonth ), pToString, pFieldOrder, pYear, pMonth ); } private void chkY( String pDateFormat, String pFieldOrder, int pYear, String pToString ) { chkY( new DateFormat( pDateFormat ), new CalendarY( pYear ), pToString, pFieldOrder, pYear ); } private void chkYMD( DateFormat pFormat, CalendarAccessorYMD pDate, String pToString, String pFieldOrder, int pYear, int pMonth, int pDay ) { assertEquals( pFieldOrder, pFormat.getFieldOrder() ); assertEquals( "Day", pDay, pDate.getDay() ); chkYMcommon( pFormat, pDate, pToString, pYear, pMonth ); } private void chkYM( DateFormat pFormat, CalendarAccessorYM pDate, String pToString, String pFieldOrder, int pYear, int pMonth ) { assertEquals( pFieldOrder, pFormat.getFieldOrder() ); chkYMcommon( pFormat, pDate, pToString, pYear, pMonth ); } private void chkY( DateFormat pFormat, CalendarAccessorY pDate, String pToString, String pFieldOrder, int pYear ) { assertEquals( pFieldOrder, pFormat.getFieldOrder() ); chkYcommon( pFormat, pDate, pToString, pYear ); } private void chkYMcommon( DateFormat pFormat, CalendarAccessorYM pDate, String pToString, int pYear, int pMonth ) { assertEquals( "Month", pMonth, pDate.getMonth() ); chkYcommon( pFormat, pDate, pToString, pYear ); } private void chkYcommon( DateFormat pFormat, CalendarAccessorY pDate, String pToString, int pYear ) { assertEquals( "Year", pYear, pDate.getYear() ); assertEquals( pToString, pFormat.format( pDate ) ); } } |
Commits for litesoft/trunk/Java/core/Server/tests/org/litesoft/core/simpletypes/temporal/DateFormatTest.java
Revision | Author | Commited | Message |
---|---|---|---|
863 Diff | GeorgeS | Fri 16 Nov, 2012 22:14:29 +0000 | |
862 Diff | GeorgeS | Thu 15 Nov, 2012 02:23:36 +0000 | On the Way... |
860 Diff | GeorgeS | Mon 05 Nov, 2012 01:39:02 +0000 | |
853 Diff | GeorgeS | Sun 04 Nov, 2012 15:18:21 +0000 | |
852 Diff | GeorgeS | Tue 30 Oct, 2012 03:34:07 +0000 | |
851 Diff | GeorgeS | Mon 08 Oct, 2012 00:05:32 +0000 | Breaking the code as Temporal changes are implemented... |
151 Diff | GeorgeS | Thu 17 Mar, 2011 04:16:22 +0000 | |
49 Diff | GeorgeS | Mon 12 Apr, 2010 02:59:10 +0000 | License Text |
2 | GeorgeS | Sun 07 Feb, 2010 12:50:58 +0000 |