Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 3 of 3

Thread: how do i get only the workig days for a certain month

  1. #1
    Junior Member
    Join Date
    Dec 2009
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question 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 :


     
    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?
    Last edited by anonimus83; December 17th, 2009 at 06:29 AM.


  2. #2
    Forum old-timer
    Join Date
    Nov 2008
    Location
    Faversham, Kent, UK
    Posts
    471
    My Mood
    Mellow
    Thanks
    4
    Thanked 58 Times in 54 Posts

    Default 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):
    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.

  3. #3
    Junior Member
    Join Date
    Dec 2009
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: how do i get only the workig days for a certain month

    Quote Originally Posted by dlorde View Post
    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):
    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