Java - Current Timestamp
Created by : Mr Dk.
2019 / 01 / 06 18:07
Nanjing, Jiangsu, China
About
ๅจ Java ไธญ่ทๅๅฝๅๆถ้ดๆณ็ๅ ็งๆนๅผใ
1. java.lang.System
long timestamp = System.currentTimeMillis();
2. java.util.Date
long timestamp = new Date().getTime();
ๅฎ็ๆบไปฃ็ ๏ผ
/**
* Allocates a <code>Date</code> object and initializes it so that
* it represents the time at which it was allocated, measured to the
* nearest millisecond.
*
* @see java.lang.System#currentTimeMillis()
*/
public Date() {
this(System.currentTimeMillis());
}
ๅฅฝๅ่ฟไธๅฆไฝฟ็จ็ฌฌไธ็งๆนๅผ๏ผ
3. java.util.Calendar
long timestamp = Calendar.getInstance().getTimeInMillis();
ๆ็ๆไฝ๏ผๆฒกๆๅฟ ่ฆใ