package com.casic.dcms.utils;

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

/**
 * @author : Pengxh
 * @time : 2021/4/15 16:54
 * @email : 290677893@qq.com
 **/
public class TimeOrDateUtil {
    private static final String TAG = "TimeOrDateUtil";
    private static SimpleDateFormat dateFormat;

    /**
     * 时间戳转时分
     */
    public static String minuteToTime(long millSeconds) {
        dateFormat = new SimpleDateFormat("HH:mm", Locale.CHINA);
        return dateFormat.format(new Date(millSeconds));
    }

    public static String getOneMonthDate() {
        dateFormat = new SimpleDateFormat("yyyy-MM-dd", Locale.CHINA);
        long oneMonth = System.currentTimeMillis() - 31 * 24 * 3600 * 1000L;
        return dateFormat.format(new Date(oneMonth));
    }

    public static String getThreeMonthDate() {
        dateFormat = new SimpleDateFormat("yyyy-MM-dd", Locale.CHINA);
        long oneMonth = System.currentTimeMillis() - 3 * 31 * 24 * 3600 * 1000L;
        return dateFormat.format(new Date(oneMonth));
    }

    public static String getSixMonthDate() {
        dateFormat = new SimpleDateFormat("yyyy-MM-dd", Locale.CHINA);
        long oneMonth = System.currentTimeMillis() - 6 * 31 * 24 * 3600 * 1000L;
        return dateFormat.format(new Date(oneMonth));
    }
}
