Java Date Calculate calculateEndDate(Date startDate, int duration)

Here you can find the source of calculateEndDate(Date startDate, int duration)

Description

calculate End Date

License

Apache License

Declaration

public static Date calculateEndDate(Date startDate, int duration) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import java.util.Calendar;
import java.util.Date;

public class Main {
    public static Date calculateEndDate(Date startDate, int duration) {
        Calendar startCal = Calendar.getInstance();

        startCal.setTime(startDate);//from  w  ww  . j  a va2 s  .co m
        for (int i = 1; i < duration; i++) {
            startCal.add(Calendar.DAY_OF_MONTH, 1);
            while (startCal.get(Calendar.DAY_OF_WEEK) == Calendar.SATURDAY
                    || startCal.get(Calendar.DAY_OF_WEEK) == Calendar.SUNDAY) {
                startCal.add(Calendar.DAY_OF_MONTH, 1);
            }
        }

        return startCal.getTime();
    }
}

Related

  1. calculate(Date d, int field, int amount)
  2. calculateByDate(Date d, int amount)
  3. calculateDate(Date date, int field, int value)
  4. calculateDays(Date startDate, Date endDate)
  5. calculateDurationEndInSec(Date start, int durationInSeconds)
  6. calculateGestationAge(Date today, Date edd)
  7. calculateLookbackDate(int lookback)
  8. calculateMonthIn(Date date1, Date date2)
  9. calculateNextSettleDate(Date date, int addMonth)