## Problem Description :

Write a program in Java that adds N working days to the current date and prints new date.

 Add n working days in current date

## Concept :

There are 5 working days per week (Monday, Tuesday, Wednesday, Thursday, Friday). Here in a loop we are adding 1 to the current date and checking day of that date. If it is Sunday or Saturday then we are doing increment to the value of N because we are interested in working days.
• We need to do addition to current date using add() method of Calendar class that accepts DAY_OF_MONTH constant and number of days that you want to add.
• For getting day, we need to use DAY_OF_WEEK constant of Calendar class.

## Java program :

```package com.javamultiplex.datetime;

import java.util.Calendar;
import java.util.Scanner;

/**
*
* @author Rohit Agarwal
* @category Date and Time
* @Problem How to add N working days to the current date?
*
*/

public static void main(String[] args) {

Scanner input = null;
try {
input = new Scanner(System.in);
System.out.println("Enter number of working days : ");
int limit = input.nextInt();
int orignalLimit = limit;
// Create Calendar class instance
Calendar calendar = Calendar.getInstance();
System.out.println("Current Date : " + calendar.getTime());
for (int i = 1; i <= limit; i++) {
// Adding 1 day to calendar.
/*
* calendar.get(Calendar.DAY_OF_WEEK) = 1 (Sunday)
* calendar.get(Calendar.DAY_OF_WEEK) = 7 (Saturday)
*
* If day is either Sunday or Saturday then it is non working
* day so Increasing the limit to compensate working days.
*/
if (calendar.get(Calendar.DAY_OF_WEEK) == 1
|| calendar.get(Calendar.DAY_OF_WEEK) == 7) {
limit++;
}
}
System.out.println("After " + orignalLimit
+ " working day/s Date : " + calendar.getTime());
} finally {
if (input != null) {
input.close();
}
}

}

}
```

## Output :

 Output - How to add N working days to the current date in Java?

## Similar Problem :

How to add N working days to the given date in Java?

Solution - This is very simple first of all Convert given String to Date and rest is same as above.

## References :

Thank you friends, I hope you have clearly understood the solution of this problem. If you have any doubt, suggestion or query please feel free to comment below. You can also discuss this solution in our forum.

Tags : Date and Time problems, Addition of n working days in Java, Solution in Java, if else statement, for loop, Calendar.