This commit is contained in:
苏竹红
2023-06-28 11:12:58 +08:00
parent 8538565dc2
commit 4e6c2d6d39
5 changed files with 23 additions and 5 deletions

View File

@@ -46,8 +46,8 @@ public class CoolDateUtils {
* @param day
* @return
*/
public static Date getDateFormatDayMinTime(int day){
LocalDate today = LocalDate.now();
public static Date getDateFormatDayMinTime(Date date,int day){
LocalDate today = date.toInstant().atZone(ZoneId.systemDefault()).toLocalDate();
LocalDate thirdDay = today.plusDays(day);
LocalDateTime thirdDayMidnight = LocalDateTime.of(thirdDay, LocalTime.MIDNIGHT);
LocalDateTime thirdDay235959 = thirdDayMidnight.with(LocalTime.MIN);
@@ -55,6 +55,16 @@ public class CoolDateUtils {
return Date.from(zonedDateTime.toInstant());
}
public static void main(String[] args) {
// 创建一个Date对象
Date date = new Date();
// 将Date对象转换为LocalDate对象
LocalDate today = date.toInstant().atZone(ZoneId.systemDefault()).toLocalDate();
System.out.println("LocalDate: " + today);
}
/**