package cn.stylefeng.workflow.instance.modular.manage.factory;

import cn.hutool.core.date.BetweenFormatter;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.ObjectUtil;

import java.util.Date;

public class DurationFactory {

    public static String durationTime(Date createTime, Date completeTime) {

        if (ObjectUtil.isEmpty(createTime)) {
            return "0分";
        }

        if (ObjectUtil.isNotEmpty(completeTime)) {
            return DateUtil.formatBetween(createTime, completeTime, BetweenFormatter.Level.MINUTE);
        } else {
            return DateUtil.formatBetween(createTime, new Date(), BetweenFormatter.Level.MINUTE);
        }
    }

}
