84669 person learning
152542 person learning
20005 person learning
5487 person learning
7821 person learning
359900 person learning
3350 person learning
180660 person learning
48569 person learning
18603 person learning
40936 person learning
1549 person learning
1183 person learning
32909 person learning
java中有没有办法获取int型的时间戳,因为之前数据库里是设计成integer的,实体类里也是integer的,所以改起来不方便。只好用int的时间戳而new Date().getTime()、Calendar.getInstance().getTimeInMillis()、System.currentTimeMillis()这三种获取的都是long类型的,有办法获取整型的吗?
new Date().getTime()、Calendar.getInstance().getTimeInMillis()、System.currentTimeMillis()
闭关修行中......
Because the database was previously designed to be integer, and the entity class was also integer, so it was inconvenient to change it
It needs to be changed even if it is inconvenient. If you want to save millisecond timestamps, you must use long,intnot enough.
long
int
Can’t you handle it yourself?For example
System.currentTimeMillis()/1000
The timestamp must be of long type. The int type cannot fit the timestamp
You can use shaping to convert to seconds or minutes, but the accuracy will be lost
It needs to be changed even if it is inconvenient. If you want to save millisecond timestamps, you must use
long
,int
not enough.Can’t you handle it yourself?
For example
The timestamp must be of long type. The int type cannot fit the timestamp
You can use shaping to convert to seconds or minutes, but the accuracy will be lost