1
21 小时以前 e0921e578658cc5181bcb9ff76f61ba47e6f0d76
lsh#
1个文件已添加
47 ■■■■■ 已修改文件
rsf-server/src/main/java/com/vincent/rsf/server/api/utils/TimeConverterUtils.java 47 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
rsf-server/src/main/java/com/vincent/rsf/server/api/utils/TimeConverterUtils.java
New file
@@ -0,0 +1,47 @@
package com.vincent.rsf.server.api.utils;
import java.util.Date;
public class TimeConverterUtils {
    /**
     * 秒级时间戳转Date
     */
    public Date timestampToDate(Long timestamp) {
        if (timestamp == null) {
            return null;
        }
        return new Date(timestamp * 1000);
    }
    /**
     * Date转秒级时间戳
     */
    public Long dateToTimestamp(Date date) {
        if (date == null) {
            return null;
        }
        return date.getTime() / 1000;
    }
    /**
     * 毫秒级时间戳转Date
     */
    public Date millisToDate(Long millis) {
        if (millis == null) {
            return null;
        }
        return new Date(millis);
    }
    /**
     * Date转毫秒级时间戳
     */
    public Long dateToMillis(Date date) {
        if (date == null) {
            return null;
        }
        return date.getTime();
    }
}