02-03-2013 10:22 AM
<activiti:formProperty id="dateFrom" name="Date from (dd-MM-yyyy)" datePattern="dd-MM-yyyy hh:mm" type="date" required="true" />
<activiti:formProperty id="dateToo" name="Date too (dd-MM-yyyy)" datePattern="dd-MM-yyyy hh:mm" type="date" required="true" />
(he say datePattern is not allowed…) (I'm using the newest version)
public void execute(DelegateExecution execution) {
StAppInfo sai = new StAppInfo ();
sai.setDateFrom((DateFormType) execution.getVariable("dateFrom"));
sai.setDateToo((DateFormType) execution.getVariable("dateToo"));
public class StAppInfo implements Serializable {
private DateFormType dateFrom;
private DateFormType dateToo;
But there I can't find a possibility to calculate the days between this two dates, or to convert this into days or minutes.02-04-2013 04:09 AM
(DateFormType) execution.getVariable("dateFrom")
02-04-2013 06:39 AM
import java.io.Serializable;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;
import java.util.Locale;
import java.util.regex.Pattern;
import org.activiti.engine.impl.form.DateFormType;
public class StapIn implements Serializable {
DateFormType dft = new DateFormType("dd-MM-yyyy");
private String dateFrom;
private String dateTo;
private long days;
public void setDateFrom(Date dateType) {
this.dateFrom = dft.convertModelValueToFormValue(dateType);
}
// for testing change DateFormType into Date
public void setDateTo(Date dateType) {
this.dateTo = dft.convertModelValueToFormValue(dateType);
}
public void setDays(long days) {
this.days = days;
}
public long getDays() {
Calendar gcFrom = new GregorianCalendar();
Calendar gcTo = new GregorianCalendar();
String dateFrom = getDateFrom();
String dateTo = getDateTo();
Date ddFrom = (Date) dft.convertFormValueToModelValue(dateFrom);
Date ddto = (Date) dft.convertFormValueToModelValue(dateTo);
gcFrom.setTime(ddFrom);
gcTo.setTime(ddto);
long time = gcTo.getTime().getTime() - gcFrom.getTime().getTime();
long day = Math.round((double) time / (24. * 60. * 60. * 1000.));
setDays(day);
return days;
}
public String getDateFrom() {
return dateFrom;
}
public String getDateTo() {
return dateTo;
}
}
Tags
Find what you came for
We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.