|
@@ -80,6 +80,9 @@ public class Dateutils {
|
|
|
public static String getDate(Date date) {
|
|
|
return new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(date);
|
|
|
}
|
|
|
+ public static String getDateDay(Date date) {
|
|
|
+ return new SimpleDateFormat("yyyy-MM-dd").format(date);
|
|
|
+ }
|
|
|
public static String getDateN(Date date) {
|
|
|
return new SimpleDateFormat("yyyyMMddHHmmss").format(date);
|
|
|
}
|
|
@@ -107,6 +110,9 @@ public class Dateutils {
|
|
|
public static String getHalfYearStr() {
|
|
|
return new SimpleDateFormat("yyyy-MM-dd").format(getHalfYear())+" 00:00:00";
|
|
|
}
|
|
|
+ public static String getHalfYearStrDay() {
|
|
|
+ return new SimpleDateFormat("yyyy-MM-dd").format(getHalfYear());
|
|
|
+ }
|
|
|
public static Date getHalfYear() {
|
|
|
Calendar c = Calendar.getInstance();
|
|
|
c.setTime(new Date());
|
|
@@ -121,10 +127,6 @@ public class Dateutils {
|
|
|
return new SimpleDateFormat("yyyy-MM-dd").format(ca.getTime()) +" 23:59:59";
|
|
|
}
|
|
|
|
|
|
- public static void main(String[] args) {
|
|
|
- String date = "2023-03-14T13:03:34.135Z";
|
|
|
- System.out.println(formatStartTime(date));
|
|
|
- }
|
|
|
|
|
|
public static String formatStartTime(String startTime) {
|
|
|
if(StringUtils.isBlank(startTime)){
|
|
@@ -139,6 +141,24 @@ public class Dateutils {
|
|
|
return endTime;
|
|
|
}
|
|
|
|
|
|
+ public static String formatStartTimeDay(String startTime) {
|
|
|
+ if(StringUtils.isBlank(startTime)){
|
|
|
+ return Dateutils.getHalfYearStrDay();
|
|
|
+ }
|
|
|
+ Date date = getDate(startTime);
|
|
|
+
|
|
|
+ return Dateutils.getDateDay(date);
|
|
|
+ }
|
|
|
+ public static String formatEndTimeDay(String endTime) {
|
|
|
+ if(StringUtils.isBlank(endTime)){
|
|
|
+ return Dateutils.getDateDay(new Date());
|
|
|
+ }
|
|
|
+
|
|
|
+ Date date = getDate(endTime);
|
|
|
+
|
|
|
+ return Dateutils.getDateDay(date);
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
public static Long getLongTime(Date useStartTime, Date useEndTime,DateUnit dateUnit) {
|
|
|
if(useStartTime == null || useEndTime == null){
|