on 12-28-2009 10:09 PM
Hi all,
I would like to determine if the day is working day given a date. I want to exclude weekend and public holidays. Is there any FM which can give me that.
Please help.
Thanks
Devang
Edited by: Diksha Chopra on Dec 29, 2009 1:28 AM
Hi
Use this
mport java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
public class WorkingDaysFinder {
static List<Date> holidayList = new ArrayList<Date>();
// holiday list
static{
holidayList.add(new Date("08/18/2009"));
holidayList.add(new Date("08/19/2009"));
}
public static void main(String args[]){
Date day1 = new Date("08/17/2009"); // start date
Date day2 = new Date("08/27/2009"); // end date
Date dayCounter = day1;
int counter = 1;
while(dayCounter.before(day2)){
// check for weekends and holiday list
if(dayCounter.getDay() != Calendar.SATURDAY &&
dayCounter.getDay()!=Calendar.SUNDAY &&
!holidayList.contains(dayCounter))
{
counter++; // count weekdays
}
dayCounter.setDate(dayCounter.getDate()+1);
}
System.out.println("Working days = "+counter);
}
}
Regards
Monika
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi
Public holidays would vary from year to year. do you want to consider some fixed public holidays like 15th aug or something whose dates do not change?
Regards
Monika
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
try this code...
Calendar cal = new GregorianCalendar(2009, Calendar.DECEMBER, 25);
int dayOfWeek = cal.get(Calendar.DAY_OF_WEEK); // 6=Friday
for calculating working days..look into the below link
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I think this post belongs in the abap general forum?
If it is a PI scenario, maybe you could send it with the rfc you are creating etc - or just receive the data and handle it at one end.
Please post more details on the scenario- and use the search feature as well
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
you have to utilize calender ,
import java.util.Calendar;
use different methods of that class.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
87 | |
10 | |
10 | |
10 | |
7 | |
6 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.