码迷,mamicode.com
首页 > 移动开发 > 详细

POI 身份证号码 手机号 日期值的处理方式

时间:2017-01-14 17:23:39      阅读:386      评论:0      收藏:0      [点我收藏+]

标签:判断   dateutil   blog   lda   获取   param   lld   电话号码   单元格   

 1 private static SimpleDateFormat dateformat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");  
 2 
 3 /**
 4      * 获取单元格的值
 5      * 
 6      * @param cell
 7      * @return
 8      */
 9     public static String getCellValue(Cell cell) {
10         DecimalFormat df = new DecimalFormat("#"); 
11         if (cell == null)
12             return "";
13 
14         if (cell.getCellType() == Cell.CELL_TYPE_STRING) {
15             return cell.getStringCellValue();
16         } else if (cell.getCellType() == Cell.CELL_TYPE_BOOLEAN) {
17             return String.valueOf(cell.getBooleanCellValue());
18         } else if (cell.getCellType() == Cell.CELL_TYPE_FORMULA) {
19             return cell.getCellFormula();
20         } else if (cell.getCellType() == Cell.CELL_TYPE_NUMERIC) {
21             if (HSSFDateUtil.isCellDateFormatted(cell)) {    //判断是日期类型  
22                 Date dt = HSSFDateUtil.getJavaDate(cell.getNumericCellValue());//获取成DATE类型     
23                 return dateformat.format(dt);   
24             }else{ //转化电话号码和身份证号码为字符串
25                 return String.valueOf(df.format(cell.getNumericCellValue()));
26             }
27             
28             
29             
30         }
31         return "";
32     }

 

POI 身份证号码 手机号 日期值的处理方式

标签:判断   dateutil   blog   lda   获取   param   lld   电话号码   单元格   

原文地址:http://www.cnblogs.com/linvan/p/6285473.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!