1
2
3
4 package org.marketchangers.prayer;
5
6
7 /***
8 * @author <a href="mailto:jniu@wc-group.com">Jianshuo Niu</a>
9 *
10 */
11 /*****************************************************
12 * this method is to valid date field, if the field is not valid under such cases:
13 * month >12 month <1, day>31 , day<1m, year<1900
14 * field can not be parsed, it will return null representing failed in date validation
15 * if the field is valid, it will return a Date object
16 * */
17 public class DateUtilTest extends junit.framework.TestCase {
18
19 public void testValidateDateField(){
20 assertTrue(DateUtil.validateDateField("02-02-2004")!=null);
21 assertTrue(DateUtil.validateDateField("02-02--2004")!=null);
22 assertEquals(DateUtil.validateDateField("13-02-2004"),null);
23 assertEquals(DateUtil.validateDateField("02-32-2004"),null);
24 assertEquals(DateUtil.validateDateField("22-32-2004"),null);
25 }
26
27 }