xujunwei 4 лет назад
Родитель
Сommit
c014c997d1

+ 12 - 8
framework-common/src/main/java/com/mrxu/framework/common/util/DateFunc.java

@@ -7,15 +7,17 @@ import java.util.Date;
 
 public class DateFunc {
 
+    public static final String TIME_FORMAT = "yyyy-MM-dd HH:mm:ss";
+
     /**
      * 特殊时间格式1
      */
-    public static final String  ZONE_TIME_FORMAT = "yyyy-MM-dd HH:mm:ss.SSSZ";
+    public static final String ZONE_TIME_FORMAT = "yyyy-MM-dd HH:mm:ss.SSSZ";
 
     /**
      * 特殊时间格式2
      */
-    public static final String  SEPECIAL_TIME_FORMAT = "yyyy-MM-dd'T'HH:mm:ssZ";
+    public static final String SEPECIAL_TIME_FORMAT = "yyyy-MM-dd'T'HH:mm:ssZ";
 
     /**
      * @Author: xujunwei
@@ -24,10 +26,12 @@ public class DateFunc {
      */ 
     public static final Date FOREVER_DATE = new Date(4092566400000l);
 
+    public static final SimpleDateFormat FORMAT = new SimpleDateFormat(TIME_FORMAT);
+
     /**
      * endFormat
      */
-    public static final SimpleDateFormat END_FORMAT = new SimpleDateFormat("yyyy-MM-dd 59:59:59");
+    public static final SimpleDateFormat END_FORMAT = new SimpleDateFormat("yyyy-MM-dd 23:59:59");
 
     /**
      * startFormat
@@ -255,13 +259,17 @@ public class DateFunc {
      **/
     public static Date getLastDayEnd(int days) {
         try {
-            return END_FORMAT.parse(getLastNDayEnd(days));
+            return FORMAT.parse(getLastNDayEnd(days));
         } catch (ParseException e) {
             e.printStackTrace();
             throw new RuntimeException("获取最近days日结束日期异常:" + e.getMessage());
         }
     }
 
+    public static void main(String[] args) {
+        System.out.println(getLastDayEnd(23));
+    }
+
     /**
      * 年月日时分秒转为年月日
      * @param date 时间
@@ -432,8 +440,4 @@ public class DateFunc {
         return new SimpleDateFormat(resultFormat).format(time);
     }
 
-    public static void main(String[] args) throws ParseException {
-        Date date = START_FORMAT.parse("2099-09-09 00:00:00");
-        System.out.println(date.getTime());
-    }
 }