I want list of date of every week based on pass dynamically Mon Tue Wed Thu Fri Sat Sun between startDate and endDate using Java 8 LocaleDate

0 votes
required List weekly date between startDate and endDate and  passing String like "Mon ,Tue, Wed, Thu, Fri, Sat, Sun" it may be fully week or custom day of week  using LocaleDate java 8

when i pass only " Wed, Thu" then every week of two date list return between startDate and endDate.
Sep 14, 2020 in Java by rkbhushan
• 190 points
1,458 views

2 answers to this question.

+1 vote

Hey, @Rkbhushan

Here goes an example regarding your query.

To list weekday names, use the getWeekdays () from the DateFormatSymbols class in Java.

DateFormatSymbols is a class for encapsulating localizable date-time formatting data.

Get weekday month names in an array −

String[] days = new DateFormatSymbols().getWeekdays ();

Display the weekdays −

for (int i = 0; i < days.length; i++) {
   String weekday = days[i];
   System.out.println(weekday);
}

Output

Sunday
Monday
Tuesday
Wednesday
Thursday
Friday
Saturday

It will be better for us to resolve your query if you kindly post your exact week based lists between the start date and end date.

answered Sep 14, 2020 by Gitika
• 65,770 points
+1 vote
public List<LocalDate> getWeeklyDateByStringofDays(String daysOfWeek, LocalDate startDate,
      LocalDate endDate) {
    final int days = (int) startDate.until(endDate, ChronoUnit.DAYS);
    return Stream.iterate(startDate, d -> d.plusDays(1))
        .limit(days)
        .filter(d -> daysOfWeek.contains(d.getDayOfWeek()
                                          .getDisplayName(TextStyle.SHORT, Locale.US)))
        .collect(Collectors.toList());
  }
answered Sep 14, 2020 by anonymous
• 190 points

Related Questions In Java

0 votes
2 answers

How do I get the current date and time using Java?

If you require a time stamp in ...READ MORE

answered Aug 23, 2019 in Java by Sirajul
• 59,230 points
2,919 views
0 votes
2 answers

Fetch list of in-between dates using Java

java.time Package The new java.time.package in Java 8 incorporates ...READ MORE

answered Aug 21, 2019 in Java by Sirajul
• 59,230 points
5,819 views
0 votes
2 answers

How can I create File and write data in it using Java?

import java.io.BufferedWriter; import java.io.IOException; import java.nio.file.Files; import java.nio.file.Paths; public class WriteFiles{ ...READ MORE

answered Jul 26, 2018 in Java by samarth295
• 2,220 points
2,915 views
0 votes
2 answers

What is the use of toString method in Java and how can I use it ?

Whenever you require to explore the constructor ...READ MORE

answered Aug 23, 2018 in Java by Daisy
• 8,140 points
4,096 views
+5 votes
4 answers

How to execute a python file with few arguments in java?

You can use Java Runtime.exec() to run python script, ...READ MORE

answered Mar 27, 2018 in Java by DragonLord999
• 8,450 points

edited Nov 7, 2018 by Omkar 81,195 views
+1 vote
1 answer

How to handle drop downs using Selenium WebDriver in Java

First, find an XPath which will return ...READ MORE

answered Mar 27, 2018 in Selenium by nsv999
• 5,500 points
8,350 views
0 votes
1 answer

What are the differences between getText() and getAttribute() functions in Selenium WebDriver?

See, both are used to retrieve something ...READ MORE

answered Apr 5, 2018 in Selenium by nsv999
• 5,500 points
17,418 views
0 votes
1 answer

Selenium JARS(Java) missing from downloadable link

Nothing to worry about here. In the ...READ MORE

answered Apr 5, 2018 in Selenium by nsv999
• 5,500 points

edited Aug 4, 2023 by Khan Sarfaraz 4,862 views
+1 vote
6 answers

How can I separate the digits of an int number in Java?

You can also have a look here: To ...READ MORE

answered Dec 9, 2020 in Java by Roshni
• 10,480 points
209,791 views
0 votes
3 answers

Setting time zone of a java.util.Date

Using Java 8 Java 8 introduced a new Date-Time ...READ MORE

answered Dec 15, 2020 in Java by Gitika
• 65,770 points
56,808 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP