字符串时间转换成毫秒值

字符串时间转换成毫秒值

 

/**
* 时间转换毫秒值
* @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;
}
}
posted @ 2021-08-10 16:23  游走人间的蒲公英  阅读(758)  评论(0编辑  收藏  举报