01: package org.geotools.feature;
02:
03: import java.util.Calendar;
04: import java.util.Date;
05:
06: import junit.framework.TestCase;
07:
08: import org.geotools.feature.type.DateUtil;
09:
10: public class DateUtilTest extends TestCase {
11:
12: public void testJavaUtilDate() {
13: Calendar cal = Calendar.getInstance();
14: cal.clear();
15: cal.set(2007, 3, 1, 1, 15);
16:
17: Date time = cal.getTime();
18: String dateTime = DateUtil.serializeDateTime(time);
19: assertEquals("2007-04-01T01:15:00", dateTime);
20: String date = DateUtil.serializeDate(time);
21: assertEquals("2007-04-01", date);
22: }
23:
24: public void testSqlDate() {
25: Calendar cal = Calendar.getInstance();
26: cal.clear();
27: cal.set(2007, 3, 1, 1, 15);
28:
29: Date time = cal.getTime();
30: java.sql.Date date = new java.sql.Date(time.getTime());
31: String dateTime = DateUtil.serializeSqlDate(date);
32: assertEquals("2007-04-01", dateTime);
33: }
34:
35: public void testSqlTime() {
36: Calendar cal = Calendar.getInstance();
37: cal.clear();
38: cal.set(2007, 3, 1, 1, 15);
39:
40: long lngTime = cal.getTime().getTime();
41: java.sql.Time time = new java.sql.Time(lngTime);
42: System.out.println(time);
43: String t = DateUtil.serializeSqlTime(time);
44: System.out.println(t);
45: assertEquals("01:15:00", t);
46: }
47:
48: }
|