单例设计模式


class DateUtil {

    private static DateUtil INSTANCE;

    private DateUtil() {
    }
    public static DateUtil getInstance() {
        if (INSTANCE == null) {
            synchronized (DateUtil.class) {
                if (INSTANCE == null) {
                    INSTANCE = new DateUtil();
                }
            }
        }
        return INSTANCE;
    }

}