Browse Source

fix 修改日期工具类,新增方法

DYH2020 1 year ago
parent
commit
3b1e4bc419
1 changed files with 21 additions and 2 deletions
  1. 21 2
      src/main/java/com/ywt/biz/common/util/DateUtil.java

+ 21 - 2
src/main/java/com/ywt/biz/common/util/DateUtil.java

@@ -15,6 +15,16 @@ public class DateUtil {
 
     private static final String[] WEEK_DAYS_MIDDLE = {"周日", "周一", "周二", "周三", "周四", "周五", "周六"};
 
+    public static final String DADE_FROMAT_YMD = "yyyy-MM-dd";
+
+    public static final String DADE_FROMAT_YMDHMS = "yyyy-MM-dd HH:mm:ss";
+
+    public static final String DADE_FROMAT_CYMD = "yyyy年M月d日";
+
+    public static final String DADE_FROMAT_CYMDHM = "yyyy年M月d日 HH:mm";
+
+
+
     /**
      * 将时间戳转换成日期字符串格式
      * @param timestamp 时间戳
@@ -215,7 +225,16 @@ public class DateUtil {
         return calendar.getTime();
     }
 
-
-
+    /**
+     * 将时间戳转换成日期字符串格式
+     *
+     * @param timestamp 时间戳
+     * @return
+     */
+    public static String convertTimestampToDateString(long timestamp) {
+        Date date = new Date(timestamp);
+        SimpleDateFormat sdf = new SimpleDateFormat(DADE_FROMAT_YMDHMS);
+        return sdf.format(date);
+    }
 
 }