poi-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Iouri Michtchenko" <Iouri.Michtche...@cern.ch>
Subject RE: Recognizing Dates
Date Wed, 12 Mar 2003 16:45:07 GMT
Hi,
I use this code:

  boolean isCellDateFormatted(HSSFWorkbook book, HSSFCell cell)
  {
    boolean result = false;
    short   format = cell.getCellStyle().getDataFormat();

    if (HSSFDateUtil.isValidExcelDate(cell.getNumericCellValue()))
    {
      if (HSSFDateUtil.isInternalDateFormat(format))
      {
        result = true;
      }
      else
      {
        String fmtText = book.createDataFormat().getFormat(format);

        if (fmtText != null 
            && ((fmtText = fmtText.toUpperCase()).indexOf("D") >= 0
                  || fmtText.indexOf("M") >= 0
                  || fmtText.indexOf("Y") >= 0
                  || fmtText.indexOf("H") >= 0
                  || fmtText.indexOf("S") >= 0))
        {
          result = true;
        }
      }
    }

    return result;
  }

I am not sure that it works in 100% of cases.

Regards,
Iouri

Mime
View raw message