litesoft
@ 853
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 |
// 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 { // Leap Day chk( new SimpleDate( 2004, 2, 29 ), "29 Feb 2004", "dMy", 2004, 2, 29 ); // exception-exception Leap Day chk( new SimpleDate( 2000, 2, 29 ), "29 Feb 2000", "dMy", 2000, 2, 29 ); chk( new SimpleDate( 1957, 1, 4 ), "04 Jan 1957", "dMy", 1957, 1, 4 ); chk( "yy", 1996, "96", "y", 1996, 0, 0 ); chk( "/yy", 1996, "/96", "y", 1996, 0, 0 ); chk( "/ y:", 1996, "/ 1996:", "y", 1996, 0, 0 ); chk( "/ yyy:", 1996, "/ 1996:", "y", 1996, 0, 0 ); chk( "MM/dd/yy", 1957, 1, 4, "01/04/57", "Mdy", 1957, 1, 4 ); chk( "init y/M/d fini", 1957, 1, 4, "init 1957/1/4 fini", "yMd", 1957, 1, 4 ); chk( "dMMM", 1957, 1, 4, "4Jan", "dM", 1957, 1, 4 ); chk( "dMMMyy", 1957, 1, 4, "4Jan57", "dMy", 1957, 1, 4 ); chk( "dMMMyy", 1957, 1, 4, "4Jan57", "dMy", 1957, 1, 4 ); chk( "d MMMM y", 1957, 1, 4, "4 January 1957", "dMy", 1957, 1, 4 ); chk( "MMMMMM y", 1957, 1, "January 1957", "My", 1957, 1, 0 ); chk( "MMMM d, y", 1957, 1, 4, "January 4, 1957", "Mdy", 1957, 1, 4 ); chk( "(M/d/y) MMMM d", 1957, 1, 4, "(1/4/1957) January 4", "Mdy", 1957, 1, 4 ); chk( "(M/d/y) ddMMM", 1957, 1, 4, "(1/4/1957) 04Jan", "Mdy", 1957, 1, 4 ); } private void chk( String pDateFormat, int pYearSrc, String pToString, String pFieldOrder, int pYear, int pMonth, int pDay ) { chk( new DateFormat( pDateFormat ), new SimpleDate( pYearSrc ), pToString, pFieldOrder, pYear, pMonth, pDay ); } private void chk( String pDateFormat, int pYearSrc, int pMonthSrc, String pToString, String pFieldOrder, int pYear, int pMonth, int pDay ) { chk( new DateFormat( pDateFormat ), new SimpleDate( pYearSrc, pMonthSrc ), pToString, pFieldOrder, pYear, pMonth, pDay ); } private void chk( String pDateFormat, int pYearSrc, int pMonthSrc, int pDaySrc, String pToString, String pFieldOrder, int pYear, int pMonth, int pDay ) { chk( new DateFormat( pDateFormat ), new SimpleDate( pYearSrc, pMonthSrc, pDaySrc ), pToString, pFieldOrder, pYear, pMonth, pDay ); } private void chk( SimpleDate pDate, String pToString, String pFieldOrder, int pYear, int pMonth, int pDay ) { chk( pDate.getDateRes().getDateFormat(), pDate, pToString, pFieldOrder, pYear, pMonth, pDay ); } private void chk( DateFormat pFormat, SimpleDate pDate, String pToString, String pFieldOrder, int pYear, int pMonth, int pDay ) { assertEquals( pFieldOrder, pFormat.getFieldOrder() ); assertEquals( "Year", pYear, pDate.getYear() ); assertEquals( "Month", pMonth, pDate.getMonth() ); assertEquals( "Day", pDay, pDate.getDay() ); assertEquals( pToString, pFormat.format( pDate ) ); } } |
Commits for litesoft/trunk/Java/core/Server/tests/org/litesoft/core/simpletypes/temporal/DateFormatTest.java
Revision | Author | Commited | Message |
---|---|---|---|
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 |