package com.unis.reserveLayout.modular.utils;

import java.text.SimpleDateFormat;
import java.time.LocalDate;
import java.util.Date;

/**
 * @author qingsong.han
 * @description: 时间格式化转换
 * @create 2024-05-16 17:47
 */
public class DateUtil {

    // 获取日期格式化
    public static String getYMD(Date param) {
        SimpleDateFormat dateTime = new SimpleDateFormat("yyyyMMdd");
        return dateTime.format(param);
    }

    // 获取前N天时间
    public static String getNDay(int param) {
        LocalDate currentDate = LocalDate.now();
        LocalDate sevenDaysAgo = currentDate.minusDays(param);
        return String.format("%s %s", sevenDaysAgo.toString(), "00:00:00");
    }

    // 获取当前时间
    public static String getNow(Date param) {
        SimpleDateFormat dateTime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        return dateTime.format(param);
    }

}
