格式化时间显示格式:
/**
* 格式化时间
*/
public void setTimes(){
SimpleDateFormat sdf = new SimpleDateFormat("yyyy:MM:dd---hh:mm:ss");
//yyyy:MM:dd---hh:mm:ss 决定了时间显示的格式
long systemTime = System.currentTimeMillis(); //获取系统时间;
String timeStr = sdf.format(new Date(systemTime));
Log.d("test", timeStr);
}
结果:
11-26 21:24:17.300: D/test(1843): 2015:11:26---09:24:17