java 获取整形时间戳
阿神
阿神 2017-04-17 17:43:34
0
4
312

java中有没有办法获取int型的时间戳,因为之前数据库里是设计成integer的,实体类里也是integer的,所以改起来不方便。只好用int的时间戳
new Date().getTime()、Calendar.getInstance().getTimeInMillis()、System.currentTimeMillis()这三种获取的都是long类型的,有办法获取整型的吗?

阿神
阿神

闭关修行中......

reply all(4)
Ty80

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.

小葫芦

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

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!