summaryrefslogtreecommitdiff
blob: b21c1d64316b8a5c3785adfd003356a292a7beeb (plain)
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
--- poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFDateUtil.java	2007/12/04 17:06:57	601004
+++ poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFDateUtil.java	2008/02/07 12:39:12	619382
@@ -228,6 +228,7 @@
     			"yyyy-mm-dd", "yyyy/mm/dd", "yy/mm/dd", "yy/mmm/dd",
     			"dd/mm/yy", "dd/mm/yyyy", "dd/mmm/yy",
     			"dd-mm-yy", "dd-mm-yyyy",
+    			"DD-MM-YY", "DD-mm-YYYY",
     			"dd\\-mm\\-yy", // Sometimes escaped
     			
     			// These crazy ones are valid
@@ -242,15 +243,33 @@
     		assertTrue( HSSFDateUtil.isADateFormat(formatId, formats[i]) );
     	}
     	
+    	// Then time based ones too
+    	formats = new String[] {
+    			"yyyy-mm-dd hh:mm:ss", "yyyy/mm/dd HH:MM:SS", 
+    			"mm/dd HH:MM", "yy/mmm/dd SS",
+    	};
+    	for(int i=0; i<formats.length; i++) {
+    		assertTrue( HSSFDateUtil.isADateFormat(formatId, formats[i]) );
+    	}
+    	
     	// Then invalid ones
     	formats = new String[] {
-    			"yyyy:mm:dd", 
+    			"yyyy*mm*dd", 
     			"0.0", "0.000",
     			"0%", "0.0%",
     			"", null
     	};
     	for(int i=0; i<formats.length; i++) {
     		assertFalse( HSSFDateUtil.isADateFormat(formatId, formats[i]) );
+    	}
+    	
+    	// And these are ones we probably shouldn't allow,
+    	//  but would need a better regexp
+    	formats = new String[] {
+    			"yyyy:mm:dd", 
+    	};
+    	for(int i=0; i<formats.length; i++) {
+    	//	assertFalse( HSSFDateUtil.isADateFormat(formatId, formats[i]) );
     	}
     }