public void setDueDateDescription(String dueDateDescription) {
ScriptManager scriptManager = EnvironmentDefaults.getScriptManager();
dueDateDescription = (String) scriptManager.evaluateExpression(dueDateDescription, null);
Duration duration = new Duration(dueDateDescription);
Date now = Clock.getCurrentTime();
if ( duration.isBusinessTime()
|| duration.getMonths()>0
|| duration.getYears()>0
) {
Environment environment = Environment.getCurrent();
if (environment==null) {
throw new JbpmException("no environment to get business calendar for calculating duedate "+dueDateDescription);
}
BusinessCalendar businessCalendar = environment.get(BusinessCalendar.class);
dueDate = businessCalendar.add(now, duration);
} else {
long millis = duration.getMillis() +
1000*( duration.getSeconds() +
60*( duration.getMinutes() +
60*( duration.getHours() +
24*( duration.getDays() +
7*duration.getWeeks()))));
dueDate = new Date(now.getTime() + millis);
}
}