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 婆婆高寿祝福语大全简短