1
1 天以前 9f43ee66e8fa2e0d02945f4bdd40d9c3a53a4bd7
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
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();
    }
}