acoliver 2002/10/01 13:40:29
Modified: src/java/org/apache/poi/hssf/usermodel HSSFDateUtil.java
Log:
you should now be able to check for date formats from the eventmodel
Revision Changes Path
1.4 +26 -14
jakarta-poi/src/java/org/apache/poi/hssf/usermodel/HSSFDateUtil.java
Index: HSSFDateUtil.java
===================================================================
RCS file:
/home/cvs/jakarta-poi/src/java/org/apache/poi/hssf/usermodel/HSSFDateUtil.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- HSSFDateUtil.java 13 Jun 2002 17:17:24 -0000 1.3
+++ HSSFDateUtil.java 1 Oct 2002 20:40:29 -0000 1.4
@@ -143,19 +143,13 @@
}
/**
- * Check if a cell contains a date
- * Since dates are stored internally in Excel as double values
- * we infer it is a date if it is formatted as such.
+ * given a format ID this will check whether the format represents
+ * an internal date format or not.
*/
- public static boolean isCellDateFormatted(HSSFCell cell) {
- if (cell == null) return false;
- boolean bDate = false;
-
- double d = cell.getNumericCellValue();
- if ( HSSFDateUtil.isValidExcelDate(d) ) {
- HSSFCellStyle style = cell.getCellStyle();
- int i = style.getDataFormat();
- switch(i) {
+ public static boolean isInternalDateFormat(int format) {
+ boolean retval =false;
+
+ switch(format) {
// Internal Date Formats as described on page 427 in
// Microsoft Excel Dev's Kit...
case 0x0e:
@@ -170,13 +164,31 @@
case 0x2d:
case 0x2e:
case 0x2f:
- bDate = true;
+ retval = true;
break;
default:
- bDate = false;
+ retval = false;
break;
}
+ return retval;
+ }
+
+ /**
+ * Check if a cell contains a date
+ * Since dates are stored internally in Excel as double values
+ * we infer it is a date if it is formatted as such.
+ * @see #isInternalDateFormat(int)
+ */
+ public static boolean isCellDateFormatted(HSSFCell cell) {
+ if (cell == null) return false;
+ boolean bDate = false;
+
+ double d = cell.getNumericCellValue();
+ if ( HSSFDateUtil.isValidExcelDate(d) ) {
+ HSSFCellStyle style = cell.getCellStyle();
+ int i = style.getDataFormat();
+ bDate = isInternalDateFormat(i);
}
return bDate;
}
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>