You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
46 lines
1.5 KiB
46 lines
1.5 KiB
13 years ago
|
--- 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]) );
|
||
|
}
|
||
|
}
|
||
|
|