# Set Due date programmatically in 6.3.x

**URL:** <https://community.ofelia.com/t/set-due-date-programmatically-in-6-3-x/5665>\
**Category:** Q&A\
**Created:** [16 February 2015 20:08 UTC](https://community.ofelia.com/t/set-due-date-programmatically-in-6-3-x/5665 "2015-02-16T20:08:42Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![epfalcon](https://avatars.discourse-cdn.com/v4/letter/e/47e85d/32.png) [@epfalcon](https://community.ofelia.com/u/epfalcon)\
**Post date:** [16 February 2015 20:08 UTC](https://community.ofelia.com/t/set-due-date-programmatically-in-6-3-x/5665/1 "2015-02-16T20:08:42Z")

</div>

Hi!  
My client has a Due date specification where depending on several factors, a due date is defined. I use a connector to get this due date, but I don’t know how to apply it to the Human task next to it.

Sure, I could use a Timer but I want to be able to see this Due date, or time left on the **Portal**. Is there a way to achieve this?

---

<div class="post-metadata">

**Author:** ![Sean\_McP](https://dub1.discourse-cdn.com/flex013/user_avatar/community.ofelia.com/sean_mcp/32/932_2.png) [@Sean\_McP](https://community.ofelia.com/u/Sean_McP)\
**Post date:** [17 February 2015 07:54 UTC](https://community.ofelia.com/t/set-due-date-programmatically-in-6-3-x/5665/2 "2015-02-17T07:54:49Z")

</div>

I use something like this…but it’s not on the next task within a process, but a new process. At least it should point you in the right direction.

By assigning the dueDate to the process it will show on the portal in the tasks List (i.e due in 2 days etc.)

//all tasks get duedate = now() + 3 days Calendar c = Calendar.getInstance(); int weekday = c.get(c.DAY\_OF\_WEEK); if (weekday == c.MONDAY){c.add(c.DAY\_OF\_MONTH,3)} if (weekday == c.TUESDAY){c.add(c.DAY\_OF\_MONTH,5)} if (weekday == c.WEDNESDAY){c.add(c.DAY\_OF\_MONTH,5)} if (weekday == c.THURSDAY){c.add(c.DAY\_OF\_MONTH,5)} if (weekday == c.FRIDAY){c.add(c.DAY\_OF\_MONTH,5)} if (weekday == c.SATURDAY){c.add(c.DAY\_OF\_MONTH,4)} if (weekday == c.SUNDAY){c.add(c.DAY\_OF\_MONTH,3)} c.setTime(new Date()); // Now use today date. c.add(Calendar.DATE, 3); // Adding 3 days

//this is the new date  
Date dueDate = c.getTime();

//Find the human activity  
SearchOptionsBuilder searchOptionsBuilder = new SearchOptionsBuilder(0, 100);  
searchOptionsBuilder.filter(HumanTaskInstanceSearchDescriptor.NAME, processIdent[0]);  
SearchOptions searchOptions = searchOptionsBuilder.done();

SearchResult searchHumanTaskInstances = processAPI.searchHumanTaskInstances(searchOptions);

```
	for (HumanTaskInstance pendingTask : searchHumanTaskInstances.getResult()) {
		
		if (pendingTask.getParentProcessInstanceId().toString().equals(processProcessId[1].toString())){
		
			if (pendingTask.getId()>activityId){

```

//got it save the activity ID  
activityId = pendingTask.getId();  
}  
}  
}

```
	//Force the date on the process Human Task...
	try{
			processAPI.updateDueDateOfTask(activityId, dueDate);
		}
		catch(Exception u1){
		}

```

Hope it helps,  
regards  
Seán
