package cn.com.qmth.stmms.biz.utils;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

public class DateFormat {

    /**
     * 获取当前时间戳
     * 
     * @return
     * @throws ParseException
     */
    public Long getDateString() {
        return System.currentTimeMillis();
    }

    /**
     * 时间戳相隔分钟
     * 
     * @return
     * @throws ParseException
     */
    public Long getDateDifference(Long oldTime) {
        return (getDateString() - oldTime) / (1000 * 60);
    }

    /*
     * 
     * 将时间转换为时间戳
     */
    public static String dateToStamp() {
        return String.valueOf(new Date().getTime());
    }

    /*
     * 将时间戳转换为时间
     */
    public static String stampToDate(String s) {
        String res;
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        long lt = new Long(s);
        Date date = new Date(lt);
        res = simpleDateFormat.format(date);
        return res;
    }

}
