package com.goer.common.utils.fisok.raw.holder;

import java.util.Date;

/**
 * @author : goer
 * @date : 2022/1/25
 * @desc : 日期保持器，把当前系统时间绑定到线程上
 */
public abstract class DateHolder {
    private static final ThreadLocal<Date> dateHolder = new ThreadLocal<Date>();
    public static Date getDate(){
        Date retDate = dateHolder.get();
        if(retDate == null) {
            retDate = new Date();
        }
        return retDate;
    }
    public static void setDate(Date date){
        dateHolder.set(date);
    }

    public static void clear() {
        dateHolder.remove();
    }
}
