传入时间 与 当前时间做比较 返回相差的日期 ---> 返回 天 时 分 秒

/**
* 返回 天 时 分 秒
* @param date 传入时间 与 当前时间做比较 返回相差的日期 ---> 返回 天 时 分 秒
* @return
*/

public static String dateToDayHourMinuteSecond(Date date){

    SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
    Date now = new Date();
    // 除以1000是为了转换成秒
    long between = (now.getTime() - date.getTime()) / 1000;
    long day = between/(24 * 3600);
    long hour = between % (24 * 3600) / 3600;
    long minute = between % 3600 / 60;
    long second = between;
    return day + "天" + hour + "时" + minute + "分" + minute + "秒";
}
posted @ 2021-07-23 14:35  仲秋呀  阅读(73)  评论(0)    收藏  举报