java中有没有办法获取int型的时间戳,因为之前数据库里是设计成integer的,实体类里也是integer的,所以改起来不方便。只好用int的时间戳
而new Date().getTime()、Calendar.getInstance().getTimeInMillis()、System.currentTimeMillis()
这三种获取的都是long类型的,有办法获取整型的吗?
PHP中文网2017-04-17 17:45:34
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
,int
not enough.
高洛峰2017-04-17 17:45:34
Can’t you handle it yourself?
For example
System.currentTimeMillis()/1000
迷茫2017-04-17 17:45:34
The timestamp must be of long type. The int type cannot fit the timestamp
巴扎黑2017-04-17 17:45:34
You can use shaping to convert to seconds or minutes, but the accuracy will be lost