Click here to Skip to main content
15,886,199 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I need to set up a logical method that finds the first working day according to the day of the given month, but I couldn't do it somehow.

What I have tried:

I just sawing in the stackoverflow but do not founded belongs to java.
Posted
Updated 3-Nov-21 20:38pm

1 solution

Assuming your working days are Monday..Friday,
then:

Find the weekday of the 1st of the month.
If it's Saturday, answer = 3,
If it's Sunday, answer = 2,
Otherwise, answer = 1.

You should be able to turn that into code on your language of choice.
 
Share this answer
 
Comments
[no name] 4-Nov-21 2:49am    
It is necessary to write a program showing the first working day of the month, provided that the holidays are taken into account.
Richard Deeming 4-Nov-21 6:05am    
Which was not mentioned anywhere in your question.

There isn't a standard list of "holidays in the month". Apart from the fact that this list would vary from country to country, or even between states within a single country, different companies might use a different list of holidays.

You're going to need to store a list of holidays somewhere, and take those into account.
[no name] 4-Nov-21 2:49am    
For example, the first working day of November 2021 starts on the 4th, because the 3rd of the month has no working days due to holidays. In short, we need to write a program that takes into account non-working days and finds the first working day of each month.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900