Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6658279
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T01:53:46+00:00 2026-05-26T01:53:46+00:00

I want to take all Saturday and Sunday from given date range… my inputs

  • 0

I want to take all Saturday and Sunday from given date range…

my inputs are

Start Date : 01/01/2011
End Date : 01/01/2012

now search date which is in between given start date and end date and day would be Saturday or Sunday.

Please Suggest…

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T01:53:47+00:00Added an answer on May 26, 2026 at 1:53 am

    Firstly, I’d recommend using Joda Time if you possibly can. It’s a much better date and time API than the one built into Java.

    Secondly, unless you’re really worried about efficiency I would personally go for the incredibly-simple-but-somewhat-wasteful approach of simply iterating over every day in the time period, and including those which fall on the right days. Alternating between adding one day and adding six days would certainly be more efficient, but harder to change.

    Sample code:

    import java.util.*;
    import org.joda.time.*;
    
    public class Test
    {
        public static void main(String[] args)
        {
            List<LocalDate> dates = getWeekendDates
                (new LocalDate(2011, 1, 1), new LocalDate(2011, 12, 1));
            for (LocalDate date : dates)
            {
                System.out.println(date);
            }
        }
    
        private static List<LocalDate> getWeekendDates
            (LocalDate start, LocalDate end)
        {
            List<LocalDate> result = new ArrayList<LocalDate>();
            for (LocalDate date = start;
                 date.isBefore(end);
                 date = date.plusDays(1))
            {
                int day = date.getDayOfWeek();
                // These could be passed in...
                if (day == DateTimeConstants.SATURDAY ||
                    day == DateTimeConstants.SUNDAY)
                {
                    result.add(date);
                }
            }
            return result;
        }                                            
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to read the company table and take out all possible suffixes from
I want to take all values after a new line character \n from my
I want to take all elements from each 2 rows if a checkbox is
I want to take advantage of DateTimePicker 's date validation, but the calendar seemed
I want to take multiple integer inputs in same line eg :- input -1
I want to make a program for Android, what take all people who use
I want to take all the articles with 'IDJurnal' last of the database this
I have a table. I want to take all ninth TDs in each TR,
In my directory, I want to run the script. The script should take all
I'm creating an ArrayList of Lat/Lon coords and then want to take all of

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.