Hi all,
I am reading data from a spreadsheet using code similar to that below.
switch (cell.getCellType()) {
...
case Cell.CELL_TYPE_NUMERIC:
if (DateUtil.isCellDateFormatted(cell)) {
// handle date type
...
}
// handle numeric type
...
}
I am running into an issue when the cell format is a custom pattern like
'yyyy-mm-dd hh:mm:ss.0'. Notice the 0 at the end of the pattern, used to
display the 10th of a second. For this cell, the
DateUtil.isCellDateFormatted(cell) is returning false and the value I am
getting is a number.
Upon inspection of the isCellDateFormatted() method, the lines
// Otherwise, check it's only made up, in any case, of:
// y m d h s - / , . :
// optionally followed by AM/PM
if(fs.matches("^[yYmMdDhHsS\\-/,. :]+[ampAMP/]*$")) {
return true;
}
do not take in to consideration the zeros that could be present in a date
pattern. According to Microsoft Office Support, "If you want to display
fractions of a second, use a number format similar to h:mm:ss.00.", found at
http://support.microsoft.com/kb/264372
Is there a workaround for determining that a cell formatted like 'yyyy-mm-dd
hh:mm:ss.0' is a Date cell? Or would I have to modify this regex pattern in
the DateUtil class in order to compensate for zeros?
Thanks in advance,
Erick Lichtas
<http://www.linomasoftware.com/> Linoma-Software-Logo
1409 Silver Street, Ashland, NE 68003
1-800-949-4696 x714
<<image002.jpg>>
