feat: There is no way the, buss state scheduled
This commit is contained in:
@@ -11,6 +11,93 @@ import java.util.*;
|
||||
*/
|
||||
public class DateUtil {
|
||||
|
||||
public static String addDay(String date, Integer dayInt) {
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
||||
Date today = null;
|
||||
try {
|
||||
today = sdf.parse(date);
|
||||
} catch (ParseException e) {
|
||||
}
|
||||
String endDate = sdf.format(today);//当前日期
|
||||
Calendar theCa = Calendar.getInstance();
|
||||
theCa.setTime(today);
|
||||
theCa.add(theCa.DATE, +dayInt);//最后一个数字30可改,30天的意思
|
||||
Date start = theCa.getTime();
|
||||
String startDate = sdf.format(start);//三十天之前日期
|
||||
|
||||
return startDate;
|
||||
}
|
||||
|
||||
public static Date nextMonthFirstDate() {
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
calendar.set(Calendar.DAY_OF_MONTH, 1);
|
||||
calendar.add(Calendar.MONTH, 1);
|
||||
return calendar.getTime();
|
||||
}
|
||||
|
||||
public static Date printToDate(String date) {
|
||||
Date date1 = null;
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
||||
try {
|
||||
date1 = sdf.parse(date);
|
||||
}catch (Exception e){
|
||||
e.getMessage();
|
||||
}
|
||||
return date1;
|
||||
}
|
||||
|
||||
public static String printDateAll(Date date) {
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
return sdf.format(date);
|
||||
}
|
||||
|
||||
public static String printDate(Date date) {
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
||||
return sdf.format(date);
|
||||
}
|
||||
|
||||
public static String firstOneDay(String date) {
|
||||
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
||||
Date today = null;
|
||||
String startDate = "";
|
||||
try {
|
||||
today = sdf.parse(date);
|
||||
String endDate = sdf.format(today);//当前日期
|
||||
Calendar theCa = Calendar.getInstance();
|
||||
theCa.setTime(today);
|
||||
theCa.add(Calendar.MONTH, 0);
|
||||
theCa.set(Calendar.DAY_OF_MONTH, 1);
|
||||
Date start = theCa.getTime();
|
||||
startDate = sdf.format(start);
|
||||
} catch (ParseException e) {
|
||||
}
|
||||
|
||||
|
||||
return startDate;
|
||||
}
|
||||
|
||||
public static String finOneDay(String date) {
|
||||
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
||||
Date today = null;
|
||||
String startDate = "";
|
||||
try {
|
||||
today = sdf.parse(date);
|
||||
String endDate = sdf.format(today);//当前日期
|
||||
Calendar theCa = Calendar.getInstance();
|
||||
theCa.setTime(today);
|
||||
theCa.set(Calendar.DAY_OF_MONTH, 1);
|
||||
theCa.set(Calendar.DATE, theCa.getActualMaximum(Calendar.DATE));
|
||||
Date start = theCa.getTime();
|
||||
startDate = sdf.format(start);
|
||||
} catch (ParseException e) {
|
||||
}
|
||||
|
||||
|
||||
return startDate;
|
||||
}
|
||||
|
||||
/**
|
||||
* 取起始时间到结束时间 所有的时间
|
||||
* @param startTime
|
||||
@@ -115,6 +202,12 @@ public class DateUtil {
|
||||
|
||||
|
||||
public static void main(String[] args) {
|
||||
System.out.println(printDate(new Date()));
|
||||
System.out.println(firstOneDay(printDate(new Date())));
|
||||
System.out.println(finOneDay(printDate(new Date())));
|
||||
System.out.println(addDay(finOneDay(printDate(new Date())),2));
|
||||
System.out.println(printDate(nextMonthFirstDate()));
|
||||
System.out.println(finOneDay(printDate(nextMonthFirstDate())));
|
||||
String utcTime = "2021-04-15T01:43:54.296Z";
|
||||
String time = formatStrUTCToDateStr("2021-04-15T01:43:54.296Z");
|
||||
System.out.println("utcTime 转换前:" + utcTime);
|
||||
|
||||
Reference in New Issue
Block a user