|
|
|
@ -11,6 +11,7 @@ import java.text.ParseException;
|
|
|
|
|
import java.text.SimpleDateFormat;
|
|
|
|
|
import java.time.*;
|
|
|
|
|
import java.time.format.DateTimeFormatter;
|
|
|
|
|
import java.time.format.DateTimeParseException;
|
|
|
|
|
import java.util.Calendar;
|
|
|
|
|
import java.util.Date;
|
|
|
|
|
import java.util.Objects;
|
|
|
|
@ -470,6 +471,62 @@ public class OrganizationDateUtil {
|
|
|
|
|
|
|
|
|
|
return localDate;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 获取一个月后的日期
|
|
|
|
|
* @param firstDate
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
public static String getLastMonthDate(String firstDate) {
|
|
|
|
|
// 定义日期格式
|
|
|
|
|
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
|
|
|
|
String nextMonthDateString = "";
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
LocalDate date = LocalDate.parse(firstDate, formatter);
|
|
|
|
|
LocalDate nextMonthDate = date.plusMonths(1);
|
|
|
|
|
nextMonthDateString = nextMonthDate.format(formatter);
|
|
|
|
|
|
|
|
|
|
} catch (DateTimeParseException e) {
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
}
|
|
|
|
|
return nextMonthDateString;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 获取一年后的日期
|
|
|
|
|
* @param firstDate
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
public static String getLastYearDate(String firstDate) {
|
|
|
|
|
// 定义日期格式
|
|
|
|
|
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
|
|
|
|
String nextYearDateString = "";
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
LocalDate date = LocalDate.parse(firstDate, formatter);
|
|
|
|
|
LocalDate nextYearDate = date.plusYears(1);
|
|
|
|
|
nextYearDateString = nextYearDate.format(formatter);
|
|
|
|
|
|
|
|
|
|
} catch (DateTimeParseException e) {
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
}
|
|
|
|
|
return nextYearDateString;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 格式化日期
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
public static String dateExample(LocalDate date) {
|
|
|
|
|
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyyMMdd");
|
|
|
|
|
return date.format(formatter);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|