Package org.apache.poi.ss.format

Examples of org.apache.poi.ss.format.CellDateFormatter$DatePartHandler


                        if(cellStyle!=null && cellStyle.getDataFormatString()!=null){
                           String dateFmt = cell.getCellStyle().getDataFormatString();
                              /* strValue = new SimpleDateFormat(dateFmt).format(date); - won't work as
                              Java fmt differs from Excel fmt. If Excel date format is mm/dd/yyyy, Java
                              will always be 00 for date since "m" is minutes of the hour.*/
                           strValue = new CellDateFormatter(dateFmt).format(hssfCell.getDateCellValue());
                        }else{
                            strValue = WebVariable.sdf.format(hssfCell.getDateCellValue());
                        }
//                        td.text(strValue);
                      }else{
                        HSSFCellStyle cellStyle = hssfCell.getCellStyle();
                        if(cellStyle!=null && cellStyle.getDataFormatString()!=null){
//                          String dataFmt = cellStyle.getDataFormatString();
                          strValue = new HSSFDataFormatter().formatRawCellContents(hssfCell.getNumericCellValue(), cellStyle.getDataFormat(), cellStyle.getDataFormatString());
                        }else{
                          strValue = String.valueOf(hssfCell.getNumericCellValue());
                        }
                      }
                    }else{
                      XSSFCell xssfCell = (XSSFCell)cell;
                      if(HSSFDateUtil.isCellDateFormatted(cell)){
                          String dateFmt = cell.getCellStyle().getDataFormatString();
                          /* strValue = new SimpleDateFormat(dateFmt).format(date); - won't work as
                          Java fmt differs from Excel fmt. If Excel date format is mm/dd/yyyy, Java
                          will always be 00 for date since "m" is minutes of the hour.*/
                          strValue = new CellDateFormatter(dateFmt).format(cell.getDateCellValue());
//                        td.text(strValue);
                      }else{
                        XSSFCellStyle cellStyle = xssfCell.getCellStyle();
                        if(cellStyle!=null && cellStyle.getDataFormatString()!=null){
//                           String dateFmt = cell.getCellStyle().getDataFormatString();
View Full Code Here

TOP

Related Classes of org.apache.poi.ss.format.CellDateFormatter$DatePartHandler

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.