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