Java程序获取当前一周中所有日期的日期
首先,获取当前日期:
LocalDate listDays = LocalDate.now();
现在,获取当前一周中所有日期的日期:
Arrays.asList(DayOfWeek.values()).stream().map(listDays::with).collect(toList()));
示例
import java.time.DayOfWeek;
import java.time.LocalDate;
import java.util.Arrays;
import static java.util.stream.Collectors.toList;
public class Demo {
public static void main(String[] args) {
LocalDate listDays = LocalDate.now();
System.out.println("All the dates for the days in the week =
\n"+Arrays.asList(DayOfWeek.values()).stream().map(listDays::with).collect(toList()));
}
}输出结果
All the dates for the days in the week = [2019-04-15, 2019-04-16, 2019-04-17, 2019-04-18, 2019-04-19, 2019-04-20, 2019-04-21]
热门推荐
10 员工对同事祝福语简短
11 送给客户的祝福语 简短
12 新年祝福语长辈简短红包
13 关于扬州的祝福语简短
14 小孩想说的祝福语简短
15 村里伴娘祝福语大全简短
16 女性生日祝福语简短优美
17 餐前仪式祝福语简短
18 宝宝生病简短祝福语大全