package com.qmth.teachcloud.eds.utils;

import org.springframework.stereotype.Component;

import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

@Component
public class DateUtils {

    private final SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");

    public static long addDate(int type, int m){
        long time = System.currentTimeMillis();
        Date d = new Date(time);
        Calendar c = Calendar.getInstance();
        c.setTime(d);
        c.add(type, m);
        return c.getTimeInMillis();
    }

    public String strDateShort(Date date){
        return simpleDateFormat.format(date);
    }
}
