时间字符串转时间SimpleDateFormat dFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
try {
Date d1 = dFormat.parse("2014-03-24 13:31:42");
ate d2 = dFormat.parse("2014-03-24 13:32:42");
long l = d2.getTime() - d1.getTime();
Log.d("time", "time"+l);
} catch (Exception e) {
// TODO: handle exception
}
时间转字符串
Time time = new Time()
time.setToNow();
String str_time2 = time.format("%Y-%m-%d %H:%M:%S");
本文展示了如何使用Java的SimpleDateFormat将时间字符串转换为时间戳,并通过实例进行了详细说明。
1185

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



