Working days calculation?

Hi everyone. I’m doing an application for legal cases reminding, and i need this functionality: I have a form with this fields: DueDate(Date and time) DaysToGo(Integer) The task i have to do is this: When i insert a date in “DueDate” field, the “DaysToGo” field has to be filled with the calculation of the DueDate – CurrentDateTime, only with the days value. The difficult part for me is to exclude the holiday days, like Saturday and Sunday. How can i achieve this via microflow? I’m actually trying with variables operations but im a bit confused. Can someone help me?thanks
1 answers

Hi , 

You can calculate working days by using Java Action.

You can create a new java action and  the following code will return the working days only 

        DateFormat df = new SimpleDateFormat("dd/MM/yyyy");
        Date date1 = df.parse(DueDate
        Date date2 = df.parse(CurrentDateTime);
        Calendar cal1 = Calendar.getInstance();
        Calendar cal2 = Calendar.getInstance();

        long numberOfDays = 0;
        while (cal1.before(cal2)) {
            if ((Calendar.SATURDAY != cal1.get(Calendar.DAY_OF_WEEK))
               &&(Calendar.SUNDAY != cal1.get(Calendar.DAY_OF_WEEK))) {
        return numberOfDays+1;


Note : The variable numberOfDays holds the value of Working days.

I hope this helps you.