package com.testor.module.video.util;

import org.springframework.util.CollectionUtils;

import java.util.Calendar;
import java.util.Date;
import java.util.HashSet;
import java.util.List;

public class ListUtils {
    public static <T> String parseListToStr(List<T> list){
        StringBuffer sb = new StringBuffer();
        if(!CollectionUtils.isEmpty(list)) {
            for(int i=0;i<=list.size()-1;i++){
                if(i<list.size()-1){
                    sb.append(list.get(i) + ",");
                }else {
                    sb.append(list.get(i));
                }
            }
        }
        return sb.toString();
    }
    public static List removeDuplicationByHashSet(List<String> list) {
        HashSet set = new HashSet(list);
        //把List集合所有元素清空
        list.clear();
        //把HashSet对象添加至List集合
        list.addAll(set);
        return list;
    }

    public static void main(String[] args) {

        Date accidentTime = new Date();
        Calendar ca = Calendar.getInstance();
        ca.setTime(accidentTime);

        int day = ca.get(Calendar.DAY_OF_MONTH);//一年中的第几天

        int week = ca.get(Calendar.HOUR_OF_DAY);//一年中的第几周

        int month = ca.get(Calendar.MONTH)+1;//第几个月 8

        int year = ca.get(Calendar.YEAR);//年份数值 2021
        System.out.println(""+year+month+day+week);
    }
}
