字符串时间转换成毫秒值

字符串时间转换成毫秒值

/**
* 时间转换毫秒值
* @param format 时间格式
* @param time 时间
* @return
*/
public static long timeToStamp(String format, String time) {
SimpleDateFormat sdf = null;
try {
sdf = new SimpleDateFormat(format);
Date date = sdf.parse(time);
return date.getTime();
} catch (Exception e) {
return -1;
}
}
原文地址:https://www.cnblogs.com/gnpugongying/p/15124458.html