浏览代码

!146 浏览代码时间字符串处理
Merge pull request !146 from 厚积薄发/master

若依 5 年之前
父节点
当前提交
56a6e940c2
共有 1 个文件被更改,包括 9 次插入1 次删除
  1. 9 1
      ruoyi-common/src/main/java/com/ruoyi/common/utils/poi/ExcelUtil.java

+ 9 - 1
ruoyi-common/src/main/java/com/ruoyi/common/utils/poi/ExcelUtil.java

@@ -224,7 +224,15 @@ public class ExcelUtil<T>
                         }
                         else
                         {
-                            val = Convert.toStr(val);
+                            String dateFormat = field.getAnnotation(Excel.class).dateFormat();
+                            if(StringUtils.isNotEmpty(dateFormat))
+                            {
+                                val=DateUtils.parseDateToStr(dateFormat,(Date) val);
+                            }
+                            else 
+                            {
+                                val = Convert.toStr(val);
+                            }
                         }
                     }
                     else if ((Integer.TYPE == fieldType) || (Integer.class == fieldType))