mirror of
https://codeup.aliyun.com/67c68d4e484ca2f0a13ac3c1/ydc/jsowell-charger-web.git
synced 2026-04-21 03:25:12 +08:00
Merge branch 'dev' of http://192.168.2.46:8099/jsowell/jsowell-charger-web into dev
This commit is contained in:
@@ -1073,6 +1073,44 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils {
|
||||
return new LocalDateTime[]{startDateTime, endDateTime};
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取去年这个月第一天的日期
|
||||
* @return 去年这个月第一天的日期,格式为 "yyyy-MM-dd"
|
||||
*/
|
||||
public static String getFirstDayOfLastYearMonth() {
|
||||
// 获取当前日期
|
||||
LocalDate currentDate = LocalDate.now();
|
||||
|
||||
// 获取去年这个月的年份
|
||||
int lastYear = currentDate.getYear() - 1;
|
||||
|
||||
// 获取这个月的月份
|
||||
int currentMonth = currentDate.getMonthValue();
|
||||
|
||||
// 获取去年这个月第一天的日期
|
||||
LocalDate firstDayOfLastYearMonth = LocalDate.of(lastYear, currentMonth, 1);
|
||||
|
||||
// 格式化日期为 "yyyy-MM-dd"
|
||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
||||
return firstDayOfLastYearMonth.format(formatter);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取当前年月最后一天的日期
|
||||
* @return 当前年月最后一天的日期,格式为 "yyyy-MM-dd"
|
||||
*/
|
||||
public static String getLastDayOfCurrentMonth() {
|
||||
// 获取当前的年份和月份
|
||||
YearMonth currentYearMonth = YearMonth.now();
|
||||
|
||||
// 获取该年月的最后一天
|
||||
LocalDate lastDayOfMonth = currentYearMonth.atEndOfMonth();
|
||||
|
||||
// 格式化日期为 "yyyy-MM-dd"
|
||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
||||
return lastDayOfMonth.format(formatter);
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
String startTime = "22:00:00";
|
||||
String endTime1 = "05:30:00";
|
||||
|
||||
Reference in New Issue
Block a user