String time = "xxxxxxx"
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd")
String plan = sdf.format()
2.再次转成Date
sdf.parse(plan)
一般用System.currentTimeMillis()或 new Date()来获取。时间戳通常是”yyyyMMddHHmmss“的,举例:
Date date = new Date()
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss")
String str = sdf.format(date)
输出结果:20160830121252。
备注:时间戳中的时间显示格式可以根据实际情况设置即可。