Android 获取当前时间戳

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
long timecurrentTimeMillis = System.currentTimeMillis();

long timeGetTime =new Date().getTime();

long timeSeconds = System.currentTimeMillis();

long timeMillis = Calendar.getInstance().getTimeInMillis();

Log.d("test", " 当前时间戳1:"+timecurrentTimeMillis);

Log.d("test", " 当前时间戳2:"+timeGetTime);

Log.d("test", " 当前时间戳3:"+timeSeconds);

Log.d("test", " 当前时间戳4:"+timeMillis);

打印结果

1
2
3
4
D/test:   当前时间戳1:1662014083840
D/test: 当前时间戳2:1662014083840
D/test: 当前时间戳3:1662014083840
D/test: 当前时间戳4:1662014083840