lizijie
2020-11-24 15ce40adc82f9277dc60ed29dad710013e99eca9
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
package com.moral.util;
 
import java.util.Date;
 
public class LengthOfTimeUtils {
 
    public static int Seconds(String time){
        String hour_minute_second = time.substring(11,19);
        String[] arr = hour_minute_second.split(":");
        int seconds = Integer.parseInt(arr[0])*3600+Integer.parseInt(arr[1])*60+Integer.parseInt(arr[2]);
        return seconds;
    }
 
    /*
     *获取精确到秒的时间戳
     */
    public static int getSecondTimestampTwo(Date date){
        if (null == date) {
            return 0;
        }
        String timestamp = String.valueOf(date.getTime()/1000);
        return Integer.valueOf(timestamp);
    }
 
}