package com.njzscloud.common.sn.support;

import cn.hutool.core.date.DateUtil;
import lombok.RequiredArgsConstructor;

import java.util.Date;

@RequiredArgsConstructor
public class TimeSection implements ISnSection {

    private final String pattern;
    private final Boolean timestamp;
    private final Integer unit;

    @Override
    public String next() {
        return timestamp ? new Date().getTime() / unit + "" : DateUtil.format(new Date(), pattern);
    }
}
