cancel
Showing results for 
Search instead for 
Did you mean: 

Determine day from date

Former Member
0 Kudos

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

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

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

Answers (4)

Answers (4)

Former Member
0 Kudos

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

Former Member
0 Kudos

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

http://www.laliluna.de/friendly-java-date-api.html

Former Member
0 Kudos

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

Former Member
0 Kudos

you have to utilize calender ,

import java.util.Calendar;

use different methods of that class.