package com.yuchen.saas.park.service.util;

import java.util.Calendar;
import java.util.Date;

/**
 * @author 刘通
 * @version 1.0
 * @date 2021/4/17 16:48
 */
@Deprecated
public class YcDateUtils {
    /**
     * 获取指定日期当天最大时间 23:59:59
     */
    public static Date getMaxDate(Date inDate) {
        Calendar calendar = Calendar.getInstance();
        calendar.setTime(inDate);
        calendar.set(Calendar.HOUR_OF_DAY, 23);
        calendar.set(Calendar.MINUTE, 59);
        calendar.set(Calendar.SECOND, 59);
        calendar.set(Calendar.MILLISECOND, 999);
        return calendar.getTime();
    }
    /**
     * 获取指定日期当天最小时间 00:00:00
     */
    public static Date getMinDate(Date inDate) {
        Calendar calendar = Calendar.getInstance();
        calendar.setTime(inDate);
        calendar.set(Calendar.HOUR_OF_DAY, 0);
        calendar.set(Calendar.MINUTE, 0);
        calendar.set(Calendar.SECOND, 0);
        calendar.set(Calendar.MILLISECOND, 0);
        return calendar.getTime();
    }
    /**
     * 获取两个日期差(分钟)
     * 超过一秒 分钟加一
     */
    public static long getMinute(Date startTime, Date endTime) {
        long l=endTime.getTime()-startTime.getTime();

        long returnMin = l/ (1000 * 60);

        long day=l/(24*60*60*1000);
        long hour=(l/(60*60*1000)-l/(24*60*60*1000)*24);
        long min=((l/(60*1000))-day*24*60-hour*60);
        long s=(l/1000-day*24*60*60-hour*60*60-min*60);
        if(s > 0) {
            returnMin +=1;
        }
        return returnMin;
    }
    /**
     * 获取两个日期差(天)
     */
    public static long getDay(Date startTime, Date endTime) {
        return (endTime.getTime() - startTime.getTime())/(1000*60*60*24);
    }
}
