package com.ruoyi.web.modules.trading.support;

import java.time.LocalDate;
import java.time.ZoneId;
import java.util.Date;
import com.ruoyi.common.exception.ServiceException;

/**
 * 预计解除日期：进场日期（日历日）+ 隔离天数（自然日）。
 */
public final class ReleaseDateCalculator
{
    private ReleaseDateCalculator()
    {
    }

    public static Date calculate(Date entryTime, int isolationDays)
    {
        if (entryTime == null)
        {
            throw new ServiceException("进场时间不能为空");
        }
        LocalDate entryDate = entryTime.toInstant().atZone(ZoneId.systemDefault()).toLocalDate();
        LocalDate release = entryDate.plusDays(isolationDays);
        return java.sql.Date.valueOf(release);
    }
}
