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 in Java by rkbhushan
• 190 points
83 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 by Gitika
• 41,360 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 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
• 58,130 points
323 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
• 58,130 points
1,282 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,200 points
320 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,110 points
1,552 views
+5 votes
3 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 6, 2018 by Omkar 31,397 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,520 points
4,492 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,520 points
10,471 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,520 points
1,904 views
0 votes
1 answer

Convert data in List<JsonNode> to Map <String,String> in Java

Hi, @Jyra, Basically, you can use the object mapper to ...READ MORE

answered Apr 7 in Java by Gitika
• 41,360 points
2,199 views
0 votes
1 answer

What is Modeshape. How can i use this?

ModeShape is an open-source implementation of the JSR-283 specification and ...READ MORE

answered Mar 30 in Java by Gitika
• 41,360 points
245 views