- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Java Program to get date for all the days of the current week
At first, get the current date:
LocalDate listDays = LocalDate.now();
Now, get the date for all the days of the current week:
Arrays.asList(DayOfWeek.values()).stream().map(listDays::with).collect(toList()));
Example
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 =
"+Arrays.asList(DayOfWeek.values()).stream().map(listDays::with).collect(toList())); } }
Output
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]
Advertisements