how do i get only the workig days for a certain month
Hi all,
i need a hand on geting only the working days for a certain month. eny ideas on haw it could be done?
basicaly, i have a web service from witch i get a xml message that contains a date.
in an action , i have a hashtable thas has as keys the only the working days for that month , starting fom the day of month that is given to me by the xml , and as value a list of quantities that i have to calculate.
untill now, i've done this :
Code :
String xmlDate = ipeList.get(a).getCOTList().get(b).getRCList().get(c).getCPList().get(d).getDQList().get(e).getDay().toString();
Hashtable<String, List<String>> dqHt = new Hashtable<String, List<String>>();
dqHt.put(xmlDate, qtyList);
String[] elementiData = xmlDate.split("/");
Calendar calendar = new GregorianCalendar();
calendar.add(Calendar.MONTH, Integer.parseInt(elementiData[1])+1);
calendar.set(GregorianCalendar.DAY_OF_MONTH, Integer.parseInt(elementiData[0]));
while(calendar.get(GregorianCalendar.MONTH) == Integer.parseInt(elementiData[1])){
calendar.add(GregorianCalendar.DAY_OF_MONTH,1);
List<String> listaVuota = new ArrayList<String>();
listaVuota.add("0");
listaVuota.add("0");
listaVuota.add("0");
dqHt.put(String.valueOf(calendar.get(Calendar.DAY_OF_MONTH)) + "/" + elementiData[1] +"/" + elementiData[2], listaVuota);
}
the problem with the code above is that it gives me all the dates ,starting width the day fom the xml, but without making the difference betwen worhing and non-working days .
how could i get only the working days?
Re: how do i get only the workig days for a certain month
It depends what the working days are - different countries and cultures may have different working days.
If you just want weekdays (Monday-Friday), just check for those days (or for not Saturday & Sunday):
Code :
boolean isSaturday = calendar.get(Calendar.DAY_OF_WEEK) == Calendar.SATURDAY;
If you want to include bank holidays and other non-working days too, you'll have to create a list of dates appropriate for your context, and check those too.
Re: how do i get only the workig days for a certain month
Quote:
Originally Posted by
dlorde
It depends what the working days are - different countries and cultures may have different working days.
If you just want weekdays (Monday-Friday), just check for those days (or for not Saturday & Sunday):
Code :
boolean isSaturday = calendar.get(Calendar.DAY_OF_WEEK) == Calendar.SATURDAY;
If you want to include bank holidays and other non-working days too, you'll have to create a list of dates appropriate for your context, and check those too.
thanks for the reply
i've resolved the problem just like you said, i've created a list of hollidays.
thank's ;)