LocalDateTime 七天后
时间: 2023-12-16 11:28:27 浏览: 221
Mysql获取当前日期的前几天日期的方法
```java
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
public class Main {
public static void main(String[] args) {
LocalDateTime now = LocalDateTime.now();
LocalDateTime after7Days = now.plusDays(7);
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
String formattedAfter7Days = after7Days.format(formatter);
System.out.println("七天后的时间为:" + formattedAfter7Days);
}
}
```
输出:
```
七天后的时间为:2022-02-22 16:08:23
```
阅读全文