时间转时间戳:
/*
* 将时间转换为时间戳
*/
public static String dateToStamp(String time) throws ParseException{
String stap;
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Date date = simpleDateFormat.parse(time);
long ts = date.getTime();//获取时间的时间戳
stap = String.valueOf(ts);
return stap;
}
时间戳转时间:
/*
* 将时间戳转换为时间
*/
public static String stampToDate(String stap){
String time;
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
long lt = new Long(stap);
Date date = new Date(lt);
time = simpleDateFormat.format(date);
return time;
}