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

  • Home
  • SEARCH
  • 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 8115891
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T03:36:42+00:00 2026-06-06T03:36:42+00:00

hi all how to generate dates if the start date and end date are

  • 0

hi all how to generate dates if the start date and end date are provided in java?

like the following :

Ex : if the start date is 15-04-2012 and end date is 15-06-2012 having this i want dates to be like the following and the list should omit saturday and sunday

1.15-04-2012,
2.16-04-2012,
3.17-04-2012,
.
.
.
.
.
.
15-06-2012

I have done like the following but it will generate for one month if the date range is of same month.
`

public static ConcurrentHashMap<String, String> getWorkingDaysMap(int year, int month, int day){
        int totalworkingdays=0,noofdays=0;
        String nameofday = "";
        ConcurrentHashMap<String,String> workingDaysMap = new ConcurrentHashMap<String,String>();
        Map<String,String> holyDayMap = new LinkedHashMap<String,String>();
        noofdays = findNoOfDays(year,month,day);

        for (int i = 1; i <= noofdays; i++) {
            Date date = (new GregorianCalendar(year,month - 1, i)).getTime(); // year,month,day
            SimpleDateFormat f = new SimpleDateFormat("EEEE");
            nameofday = f.format(date);

            String daystr="";
            String monthstr="";

            if(i<10)daystr="0";
            if(month<10)monthstr="0";

            String formatedDate = daystr+i+"/"+monthstr+month+"/"+year;

            if(!(nameofday.equals("Saturday") || nameofday.equals("Sunday"))){
                workingDaysMap.put(formatedDate,formatedDate);
                totalworkingdays++;
            }
        }

        return workingDaysMap;
    }

So please do advice me how to go about.

Regards
Tony

  • 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-06-06T03:36:43+00:00Added an answer on June 6, 2026 at 3:36 am

    use the following joda-time

    import org.joda.time.DateTimeConstants;
    import org.joda.time.LocalDate;
    
    public class DatesexcludingWeekend {
        public static void main(String[] args) {
            final LocalDate start = new LocalDate(2012, 06, 15);
            final LocalDate end = new LocalDate(2012, 07, 14);
            LocalDate weekday = start;
            if (start.getDayOfWeek() == DateTimeConstants.SATURDAY|| start.getDayOfWeek() == DateTimeConstants.SUNDAY) {
                weekday = weekday.plusWeeks(1).withDayOfWeek(DateTimeConstants.MONDAY);
            }
    
            while (weekday.isBefore(end)) {
                System.out.println(weekday);
                if (weekday.getDayOfWeek() == DateTimeConstants.FRIDAY)
                    weekday = weekday.plusDays(3);
                else
                    weekday = weekday.plusDays(1);
            }
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: How to generate all permutations of a list in Python I want
Given the following list of descending unique numbers (3,2,1) I wish to generate all
If I was to given a specific java.util.Date, how can I generate a start
I know you can generate all permutations from a list, using glob or Algorithm::Permute
I want to generate a choicelist for all specs that inherit from imagekit.specs.ImageSpec .
A table exists in Microsoft SQL Server with record ID, Start Date, End Date
I'm using FPDF (generate PDF from PHP). I want to show all the items
Algorithm to generate all possible letter combinations of given string down to 2 letters
I need to generate all combinations (not permutations) in VB .NET, I've been search
My app uses javascript to generate all the HTML for my website. The index.html

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.