修改时间
This commit is contained in:
@@ -49,15 +49,23 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils
|
||||
* @return 当天日期的字符串,例如:2026-01-27
|
||||
*/
|
||||
public static String getTodayDate() {
|
||||
LocalDateTime now = LocalDateTime.now();
|
||||
LocalTime thresholdTime = LocalTime.of(6, 1, 0);
|
||||
LocalDate date;
|
||||
if (now.toLocalTime().isBefore(thresholdTime)) {
|
||||
date = now.toLocalDate().minusDays(1); // 昨天
|
||||
} else {
|
||||
date = now.toLocalDate(); // 今天
|
||||
}
|
||||
return date.format(DateTimeFormatter.ofPattern(YYYY_MM_DD));
|
||||
}
|
||||
/*public static String getTodayDate() {
|
||||
LocalDate today = LocalDate.now();
|
||||
return today.format(DateTimeFormatter.ofPattern(YYYY_MM_DD));
|
||||
}
|
||||
}*/
|
||||
|
||||
public static void main(String[] args) {
|
||||
List<String> test = new ArrayList<>();
|
||||
test.add("12312");
|
||||
test.add("12312");
|
||||
System.out.println("====="+test.get(6));
|
||||
System.out.println("====="+getTodayDate());
|
||||
/* Date now = new Date(); // 当前时间
|
||||
Date fifteenMinutesAgo = DateUtil.offsetMinute(now, -15); // 15分钟前的时间
|
||||
|
||||
|
||||
Reference in New Issue
Block a user