public static Long getTimeStemp(String str){
long time = 0;
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Date d = null;
try {
d = sdf.parse(str);
} catch (ParseException e) {
e.printStackTrace();
}
if(d != null){
time = d.getTime();
}
return time / 1000;
}
本文详细解释了如何使用Java的SimpleDateFormat类将日期字符串转换为时间戳,并通过实例代码展示了具体实现过程。
841

被折叠的 条评论
为什么被折叠?



