package com.bpmn.Rechnungseingang;

import java.util.Date;
import java.util.concurrent.TimeUnit ;
import org.camunda.bpm.engine.delegate.DelegateExecution;

import org.camunda.bpm.engine.delegate.JavaDelegate;

public class BerechnungZahlungsziel implements JavaDelegate {

	@Override
	public void execute(DelegateExecution execution) throws Exception {
		Date zahlungsziel = (Date)execution.getVariable("FormField_date_Zahlungsziel");
		Date aktuellesDatum = new Date(System.currentTimeMillis());
		
	    long diffInMillies = Math.abs(zahlungsziel.getTime() - System.currentTimeMillis());
	    long diff = TimeUnit.HOURS.convert(diffInMillies, TimeUnit.MILLISECONDS);
	    
		System.out.println("Differenz: "+ diff);
		
		execution.setVariable("FormField_bool_Zahlungsziel", true);
				
	}

}
