zuoxiao
2024-03-04 275fbc47873d5c4f78a57b4fa58a08e2e7af2dc2
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
package com.dayu.recharge.utils;
 
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
 
/**
 * Created by zuoxiao on 2018/12/24.
 */
 
public class DateUtil {
 
 
    public static String type1 = "yyyy-MM-dd HH:mm";
    public static String type2 = "yyyy-MM-dd HH:mm:ss";
 
 
    /*
     * 将时间转换为时间戳
     */
    public static String dateToStamp(long ts, String type) {
        String res = "";
        try {
            SimpleDateFormat simpleDateFormat = new SimpleDateFormat(type);
            Date d1 = new Date(ts);
            return simpleDateFormat.format(d1);
 
        } catch (Exception e) {
            e.printStackTrace();
        }
        return res;
    }
 
 
}